コード例 #1
0
 public function testConnectionWithFilesystemManagerAndCacheManager()
 {
     $manager = $this->mock(FilesystemManager::class);
     $cacheManager = $this->mock(CacheManagerContract::class);
     $cacheManager->shouldReceive('hasDriver')->once()->with('array')->andReturn(true);
     $cacheManager->shouldReceive('driver')->once()->andReturn(new ArrayCachePool());
     $cache = new CachedFactory($manager, $cacheManager);
     $adapter = $cache->connection(['cache' => ['driver' => 'array', 'name' => 'array', 'key' => 'test', 'expire' => 6000]]);
     $this->assertInstanceOf(CacheInterface::class, $adapter);
 }
コード例 #2
0
 /**
  * Adapt the filesystem implementation.
  *
  * @param \League\Flysystem\AdapterInterface $adapter
  * @param array                              $config
  *
  * @return \Viserio\Contracts\Filesystem\Filesystem
  */
 protected function adapt(AdapterInterface $adapter, array $config) : FilesystemContract
 {
     if (isset($config['cache']) && is_array($config['cache'])) {
         $cacheFactory = new CachedFactory($this, $this->cache);
         $adapter = new CachedAdapter($adapter, $cacheFactory->connection($config));
     }
     $filesystemAdapter = new FilesystemAdapter($adapter);
     return $filesystemAdapter;
 }