コード例 #1
0
 public function createCachePool()
 {
     // we need this, as memory storage goes way when the instances looses scope
     if (null === $this->memoryCache) {
         $this->memoryCache = CacheFactory::make(CacheFactory::MEMORY);
     }
     return $this->memoryCache;
 }
コード例 #2
0
 public function testTwoLevelCacheSaveAndFetch()
 {
     $memory1 = CacheFactory::make(CacheFactory::MEMORY);
     $memory2 = CacheFactory::make(CacheFactory::MEMORY);
     $cache = CacheFactory::make(CacheFactory::TWO_LEVEL, $memory1, $memory2);
     $item = $cache->getItem('key')->set('value');
     $cache->save($item);
     // assert that both caches have the item
     $this->assertTrue($memory1->getItem('key')->isHit());
     $this->assertTrue($memory2->getItem('key')->isHit());
     // hack and delete on first cache
     $memory1->clear();
     $this->assertTrue($cache->getItem('key')->isHit());
 }
コード例 #3
0
 public function createCachePool()
 {
     return CacheFactory::make(CacheFactory::FILE);
 }
コード例 #4
0
 public function testFileCacgeFactory()
 {
     $cache = CacheFactory::make(CacheFactory::FILE);
     $this->assertInstanceOf('Psr\\Cache\\CacheItemPoolInterface', $cache);
 }
コード例 #5
0
 private function getSecondLevelCache()
 {
     $redisClient = new Redis();
     $redisClient->connect('127.0.0.1');
     return CacheFactory::make(CacheFactory::REDIS, $redisClient);
 }
コード例 #6
0
 public function createCachePool()
 {
     $redisClient = new Redis();
     $redisClient->connect('127.0.0.1');
     return CacheFactory::make(CacheFactory::REDIS, $redisClient);
 }
コード例 #7
0
 public function createCachePool()
 {
     $memcached = new Memcached('cant');
     $memcached->addServer('localhost', 11211);
     return CacheFactory::make(CacheFactory::MEMCACHED, $memcached);
 }