public function testDeleteSingleContainer()
 {
     $blobStore = new BlobStore('Foo', $this->cache);
     $container = $blobStore->read('foobar');
     $container->set('one', 42);
     $blobStore->save($container);
     $this->assertTrue($blobStore->exists('foobar'));
     $blobStore->delete('foobar');
     $this->assertFalse($blobStore->exists('foobar'));
 }
 /**
  * @since 2.5
  *
  * @param DIWikiPage|array $list
  */
 public function resetCacheBy($item)
 {
     if (!is_array($item)) {
         $item = array($item);
     }
     $recordStats = false;
     foreach ($item as $id) {
         $id = $this->getHashFrom($id);
         if ($this->blobStore->exists($id)) {
             $recordStats = true;
             $this->transientStatsdCollector->incr('deletes');
             $this->blobStore->delete($id);
         }
     }
     if ($recordStats) {
         $this->recordStats();
     }
 }
 /**
  * Remove a cache item that appears during an alteration action (update,
  * change, delete) to ensure that we always have the correct set of matches.
  *
  * @since 2.3
  *
  * @param DIWikiPage|null $subject
  */
 public function resetCacheBy(DIWikiPage $subject = null)
 {
     if (!$this->blobStore->canUse() || $subject === null) {
         return null;
     }
     // Remove a redirect target subject directly
     $redirects = $this->getSemanticData($subject)->getPropertyValues(new DIProperty('_REDI'));
     foreach ($redirects as $redirectTarget) {
         $this->blobStore->delete($this->getHashFrom($redirectTarget));
     }
     $sid = $this->getHashFrom($subject);
     // Remove all linked objects
     $container = $this->blobStore->read($sid);
     if ($container->has('list')) {
         foreach (array_keys($container->get('list')) as $id) {
             $this->blobStore->delete($id);
         }
     }
     $this->blobStore->delete($sid);
 }
Beispiel #4
0
 public function testDeleteContainerForSpecificId()
 {
     $this->cache->expects($this->once())->method('delete')->with($this->equalTo('blobstore:Foo:bar'));
     $instance = new BlobStore('Foo', $this->cache);
     $instance->delete('bar');
 }
Beispiel #5
0
 public function testDeleteMembersOfLinkedListAsWell()
 {
     $linkedContainer = serialize(array('@linkedList' => array('a42b' => true)));
     $this->cache->expects($this->once())->method('contains')->with($this->equalTo('blobstore:Foo:Bar'))->will($this->returnValue(true));
     $this->cache->expects($this->once())->method('fetch')->will($this->returnValue($linkedContainer));
     $this->cache->expects($this->at(2))->method('delete')->with($this->equalTo('blobstore:Foo:a42b'));
     $this->cache->expects($this->at(3))->method('delete')->with($this->equalTo('blobstore:Foo:Bar'));
     $instance = new BlobStore('Foo', $this->cache);
     $instance->delete('Bar');
 }
 /**
  * @since 2.4
  */
 public function resetCacheBy(DIWikiPage $subject)
 {
     $this->blobStore->delete($this->getRootHashFrom($subject));
 }