Пример #1
0
 public function testCanConstructFixedInMemoryLruCache()
 {
     $instance = new CacheFactory();
     $this->assertInstanceOf('\\Onoi\\Cache\\FixedInMemoryLruCache', $instance->newFixedInMemoryLruCache(1));
     // Legacy
     $this->assertInstanceOf('\\Onoi\\Cache\\FixedInMemoryLruCache', $instance->newFixedInMemoryCache(1));
 }
 protected function setUp()
 {
     if (!class_exists('\\Onoi\\Cache\\CacheFactory')) {
         $this->markTestSkipped('CacheFactory is not available');
     }
     $cacheFactory = new CacheFactory();
     $this->cache = $cacheFactory->newFixedInMemoryLruCache(500);
 }
 public function testCachedQueuedResponse()
 {
     $this->connectToHttpd();
     $expectedToCount = 5;
     $cacheFactory = new CacheFactory();
     $httpRequestFactory = new HttpRequestFactory($cacheFactory->newFixedInMemoryLruCache());
     $asyncCurlRequest = $httpRequestFactory->newAsyncCurlRequest();
     for ($i = 0; $i < $expectedToCount; $i++) {
         $asyncCurlRequest->addHttpRequest($httpRequestFactory->newCachedCurlRequest($this->getHttpdRequestUrl($i)));
     }
     $this->assertCount($expectedToCount, $asyncCurlRequest->execute());
 }
 protected function setUp()
 {
     $cache = array();
     $cacheFactory = new CacheFactory();
     $cache[] = $cacheFactory->newFixedInMemoryLruCache();
     if (class_exists('\\HashBagOStuff')) {
         $cache[] = $cacheFactory->newMediaWikiCache(new HashBagOStuff());
     }
     if (class_exists('\\Doctrine\\Common\\Cache\\ArrayCache')) {
         $cache[] = $cacheFactory->newDoctrineCache(new ArrayCache());
     }
     $this->cache = $cacheFactory->newCompositeCache($cache);
 }