Ejemplo n.º 1
0
 /**
  * Loads a cached resource
  * 
  * @param ResourceInterface $resource
  * 
  * @return array 
  */
 public function load(ResourceInterface $resource)
 {
     if (!$resource instanceof CacheResource) {
         return array();
     }
     if (!$this->cache->has($resource->getName())) {
         return array();
     }
     $formulas = unserialize($this->cache->get($resource->getName()));
     foreach ($formulas as $idx => $formula) {
         $formulas[$idx] = $this->restoreFormulaFilters($formula);
     }
     return $formulas;
 }
Ejemplo n.º 2
0
 /**
  * Applies dump filters and returns the asset as a string.
  *
  * @param  FilterInterface|null $additionalFilter
  * @return string
  */
 public function dump(FilterInterface $additionalFilter = null)
 {
     $cacheKey = $this->getCacheKey($this->asset, $additionalFilter, 'dump');
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $content = $this->asset->dump($additionalFilter);
     $this->cache->set($cacheKey, $content);
     return $content;
 }
 /**
  * Searches a fresh cached file for the given file.
  *
  * @throws RuntimeException filesystem errors
  */
 private function getCache($file)
 {
     if (null === $this->cache) {
         return null;
     }
     $key = md5($file);
     // File already present
     if ($this->cache->has($key)) {
         list($mtime, $path) = unserialize($this->cache->get($key));
         if ($mtime === filemtime($file)) {
             return $path;
         }
         $delete = $this->directory . '/' . $path;
         if (file_exists($delete) && false === @unlink($delete)) {
             throw new \RuntimeException('Unable to remove file ' . $delete);
         }
     }
     return null;
 }
 /**
  * Remove this key from session and also remove it from
  * underlying cache driver
  *
  * @param  string $key
  * @return string
  */
 public function remove($key)
 {
     return $this->cache->remove($key);
 }