Ejemplo n.º 1
0
 protected function expired()
 {
     $viewRedis = container()->getViewRedis();
     if (true !== $viewRedis) {
         if (!File::exists($this->compiled()) || !File::exists($this->_viewFile)) {
             return true;
         }
         return File::modified($this->_viewFile) > File::modified($this->compiled());
     } else {
         $key = sha1($this->_viewFile) . '::age';
         $age = context()->redis()->get($key);
         if (strlen($age)) {
             $age = (int) $age;
             return File::modified($this->_viewFile) || File::modified(__FILE__) > $age;
         }
         return true;
     }
 }
Ejemplo n.º 2
0
 private static function _buffer($key, $data = null)
 {
     if (false === static::$_buffer) {
         return false;
     }
     $timeToBuffer = false !== static::$_cache ? static::$_cache * 60 : 2;
     $ext = false !== static::$_cache ? 'cache' : 'buffer';
     $file = CACHE_PATH . DS . $key . '_nosql.' . $ext;
     if (File::exists($file)) {
         $age = time() - File::modified($file);
         if ($age > $timeToBuffer) {
             File::delete($file);
         } else {
             return static::unserialize(static::load($file));
         }
     }
     if (null === $data) {
         return false;
     }
     File::put($file, static::serialize($data));
 }