コード例 #1
0
ファイル: FileManager.php プロジェクト: romeoz/rock-file
 /**
  * @inheritdoc
  */
 public function __construct($config = [])
 {
     $this->parentConstruct($config);
     if ($this->cache instanceof CacheInterface) {
         $this->cache->save();
         $this->adapter = new CachedAdapter($this->adapter, $this->cache);
     }
     parent::__construct($this->adapter, $this->config);
     $this->addPlugin(new ListPaths());
     $this->addPlugin(new ListWith());
     $this->addPlugin(new GetWithMetadata());
 }
コード例 #2
0
 protected function make_it_cache_getter($method, $path, $response)
 {
     $this->cache->{$method}($path)->willReturn(false);
     $this->adapter->{$method}($path)->willReturn($response);
     $this->cache->updateObject($path, $response, true)->shouldBeCalled();
     $this->{$method}($path)->shouldBe($response);
 }
コード例 #3
0
 /**
  * Configure after successful mount.
  *
  * @return void
  **/
 protected function configure()
 {
     parent::configure();
     if ($this->fscache && $this->isMyReload()) {
         $this->fscache->flush();
     }
 }
コード例 #4
0
ファイル: Cached.php プロジェクト: bolt/filesystem
 /**
  * {@inheritdoc}
  */
 public function getImageInfo($path)
 {
     // If cache doesn't support image info, just pass through to adapter.
     if (!$this->cache instanceof Capability\ImageInfo) {
         return $this->doGetImageInfo($path);
     }
     // Get from cache.
     $info = $this->cache->getImageInfo($path);
     if ($info !== false) {
         return is_array($info) ? Image\Info::createFromJson($info) : $info;
     }
     // Else from adapter.
     $info = $this->doGetImageInfo($path);
     // Save info from adapter.
     $object = ['path' => $path, 'image_info' => $info];
     $this->cache->updateObject($path, $object, true);
     return $info;
 }
コード例 #5
0
 /**
  * Call a method and cache the response.
  *
  * @param string $method
  * @param string $path
  *
  * @return mixed
  */
 protected function callWithFallback($method, $path)
 {
     $result = $this->cache->{$method}($path);
     if ($result !== false) {
         return $result;
     }
     $result = $this->adapter->{$method}($path);
     if ($result) {
         $object = $result + compact('path');
         $this->cache->updateObject($path, $object, true);
     }
     return $result;
 }