/** * @since 2.5 * * @return EntityLookup */ public function newEntityLookup() { $settings = $this->applicationFactory->getSettings(); $directEntityLookup = new DirectEntityLookup($this->store); if ($settings->get('smwgValueLookupCacheType') === CACHE_NONE) { return $directEntityLookup; } $circularReferenceGuard = new CircularReferenceGuard('vl:store'); $circularReferenceGuard->setMaxRecursionDepth(2); $cacheFactory = $this->applicationFactory->newCacheFactory(); $blobStore = $cacheFactory->newBlobStore('smw:vl:store', $settings->get('smwgValueLookupCacheType'), $settings->get('smwgValueLookupCacheLifetime')); $cachedEntityLookup = new CachedEntityLookup($directEntityLookup, new RedirectTargetLookup($this->store, $circularReferenceGuard), $blobStore); $cachedEntityLookup->setCachedLookupFeatures($settings->get('smwgValueLookupFeatures')); return $cachedEntityLookup; }
public function testResetCacheBy() { $subject = new DIWikiPage('Foobar', NS_MAIN, '', 'abc'); $semanticData = new SemanticData($subject); $semanticData->addPropertyObjectValue(new DIProperty('_REDI'), new DIWikiPage('Bar', NS_MAIN)); $container = $this->getMockBuilder('\\Onoi\\BlobStore\\Container')->disableOriginalConstructor()->getMock(); $container->expects($this->at(0))->method('has')->with($this->stringContains('sd:'))->will($this->returnValue(true)); $container->expects($this->at(1))->method('get')->with($this->stringContains('sd:'))->will($this->returnValue($semanticData)); $container->expects($this->at(2))->method('has')->with($this->stringContains('list'))->will($this->returnValue(true)); $container->expects($this->at(3))->method('get')->with($this->stringContains('list'))->will($this->returnValue(array('abc', '123'))); $this->blobStore->expects($this->any())->method('canUse')->will($this->returnValue(true)); $this->blobStore->expects($this->atLeastOnce())->method('read')->will($this->returnValue($container)); $this->blobStore->expects($this->exactly(4))->method('delete'); $instance = new CachedEntityLookup($this->entityLookup, $this->redirectTargetLookup, $this->blobStore); $instance->setCachedLookupFeatures(SMW_VL_SD); $instance->resetCacheBy($subject); }