public function testEntityDeleted()
 {
     $mock = new MockRepository();
     $id = new ItemId('Q123');
     $item = new Item($id);
     $mock->putEntity($item, 11);
     $lookup = new CachingEntityRevisionLookup($mock, new HashBagOStuff());
     $lookup->setVerifyRevision(false);
     // fetch first revision, so it gets cached
     $lookup->getEntityRevision($id);
     // remove entity
     $mock->removeEntity($id);
     // now, notify the cache
     $lookup->entityDeleted($id);
     // make sure we get the new revision now
     $revId = $lookup->getLatestRevisionId($id);
     $this->assertFalse($revId, 'deletion should be detected after notification');
     $rev = $lookup->getEntityRevision($id);
     $this->assertNull($rev, 'deletion should be detected after notification');
 }
 /**
  * Creates a strongly connected pair of EntityRevisionLookup services, the first being the raw
  * uncached lookup, the second being the cached lookup.
  *
  * @return array( WikiPageEntityRevisionLookup, CachingEntityRevisionLookup )
  */
 private function newEntityRevisionLookup()
 {
     // NOTE: Keep cache key in sync with DirectSqlStore::newEntityRevisionLookup in WikibaseClient
     $cacheKeyPrefix = $this->cacheKeyPrefix . ':WikiPageEntityRevisionLookup';
     // Maintain a list of watchers to be notified of changes to any entities,
     // in order to update caches.
     /** @var WikiPageEntityStore $dispatcher */
     $dispatcher = $this->getEntityStoreWatcher();
     $metaDataFetcher = $this->getEntityPrefetcher();
     $dispatcher->registerWatcher($metaDataFetcher);
     $rawLookup = new WikiPageEntityRevisionLookup($this->contentCodec, $metaDataFetcher, false);
     // Lower caching layer using persistent cache (e.g. memcached).
     $persistentCachingLookup = new CachingEntityRevisionLookup($rawLookup, wfGetCache($this->cacheType), $this->cacheDuration, $cacheKeyPrefix);
     // We need to verify the revision ID against the database to avoid stale data.
     $persistentCachingLookup->setVerifyRevision(true);
     $dispatcher->registerWatcher($persistentCachingLookup);
     // Top caching layer using an in-process hash.
     $hashCachingLookup = new CachingEntityRevisionLookup($persistentCachingLookup, new HashBagOStuff());
     // No need to verify the revision ID, we'll ignore updates that happen during the request.
     $hashCachingLookup->setVerifyRevision(false);
     $dispatcher->registerWatcher($hashCachingLookup);
     return array($rawLookup, $hashCachingLookup);
 }
 /**
  * @return EntityRevisionLookup
  */
 private function newEntityRevisionLookup()
 {
     // NOTE: Keep cache key in sync with SqlStore::newEntityRevisionLookup in WikibaseRepo
     $cacheKeyPrefix = $this->cacheKeyPrefix . ':WikiPageEntityRevisionLookup';
     $metaDataFetcher = $this->getEntityPrefetcher();
     $rawLookup = new WikiPageEntityRevisionLookup($this->contentCodec, $metaDataFetcher, $this->repoWiki);
     // Lower caching layer using persistent cache (e.g. memcached).
     $persistentCachingLookup = new CachingEntityRevisionLookup($rawLookup, wfGetCache($this->cacheType), $this->cacheDuration, $cacheKeyPrefix);
     // We need to verify the revision ID against the database to avoid stale data.
     $persistentCachingLookup->setVerifyRevision(true);
     // Top caching layer using an in-process hash.
     $hashCachingLookup = new CachingEntityRevisionLookup($persistentCachingLookup, new HashBagOStuff());
     // No need to verify the revision ID, we'll ignore updates that happen during the request.
     $hashCachingLookup->setVerifyRevision(false);
     return $hashCachingLookup;
 }