コード例 #1
0
ファイル: NsCache.php プロジェクト: maslosoft/addendum
 public function get()
 {
     if (!empty(self::$nsCache[$this->file])) {
         return self::$nsCache[$this->file];
     }
     self::$nsCache[$this->file] = SoftIncluder::includeFile($this->file);
     return self::$nsCache[$this->file];
 }
コード例 #2
0
ファイル: PhpCache.php プロジェクト: maslosoft/addendum
 public function get()
 {
     $this->prepare();
     $fileName = $this->getFilename();
     if (NsCache::$addeNs && !$this->nsCache->valid()) {
         $this->clearCurrentPath();
         return false;
     }
     $key = $this->getCacheKey();
     if (isset(self::$cache[$key])) {
         return self::$cache[$key];
     }
     $data = SoftIncluder::includeFile($fileName);
     // Only false means not existing cache.
     // NOTE: Cache might have valid `empty` value, ie. empty array.
     if (false === $data) {
         return false;
     }
     // Purge file cache if checkMTime is enabled and file obsolete
     if ($this->addendum->checkMTime && file_exists($fileName)) {
         $cacheTime = filemtime($fileName);
         // Partial component name, split by @ and take first argument
         if (is_string($this->component) && strstr($this->component, '@')) {
             $parts = explode('@', $this->component);
             $componentClass = array_shift($parts);
         } else {
             $componentClass = $this->component;
         }
         $componentTime = filemtime((new ReflectionClass($componentClass))->getFileName());
         if ($componentTime > $cacheTime) {
             $this->remove();
             return false;
         }
     }
     self::$cache[$key] = $data;
     return $data;
 }