Пример #1
0
 public function testClear()
 {
     $instance = CacheFactory::getInstance();
     $this->assertSame($instance, CacheFactory::getInstance());
     $instance->clear();
     $this->assertNotSame($instance, CacheFactory::getInstance());
 }
Пример #2
0
 /**
  * @since 1.0
  *
  * @param string $namespace
  * @param Cache $cache
  */
 public function __construct($namespace, Cache $cache)
 {
     if (!is_string($namespace)) {
         throw new InvalidArgumentException("Expected the namespace to be a string");
     }
     $this->namespace = $namespace;
     $this->cache = $cache;
     // It is only used internally therefore no injection required as it improves
     // performance on long lists as seen in #1
     $this->internalCache = CacheFactory::getInstance()->newFixedInMemoryLruCache(500);
 }
 /**
  * @since 2.2
  *
  * @param integer|string $mediaWikiCacheType
  *
  * @return Cache
  */
 public function newMediaWikiCompositeCache($mediaWikiCacheType = null)
 {
     $mediaWikiCache = ObjectCache::getInstance($mediaWikiCacheType === null ? $this->getMainCacheType() : $mediaWikiCacheType);
     $compositeCache = OnoiCacheFactory::getInstance()->newCompositeCache(array($this->newFixedInMemoryCache(500), OnoiCacheFactory::getInstance()->newMediaWikiCache($mediaWikiCache)));
     return $compositeCache;
 }