findIdentifiersByTag() public method

Finds and returns all cache entry identifiers which are tagged by the specified tag.
public findIdentifiersByTag ( string $tag ) : array
$tag string The tag to search for
return array An array with identifiers of all matching entries. An empty array if no entries matched
コード例 #1
0
 /**
  * @test
  */
 public function removeRemovesEntryFromCache()
 {
     for ($i = 0; $i < 10; $i++) {
         $this->backend->set('entry_' . $i, 'foo', ['tag1']);
     }
     $this->assertCount(10, $this->backend->findIdentifiersByTag('tag1'));
     $this->assertEquals('foo', $this->backend->get('entry_1'));
     $actualEntries = [];
     foreach ($this->backend as $key => $value) {
         $actualEntries[] = $key;
     }
     $this->assertCount(10, $actualEntries);
     $this->backend->remove('entry_3');
     $this->assertCount(9, $this->backend->findIdentifiersByTag('tag1'));
     $this->assertFalse($this->backend->get('entry_3'));
     $actualEntries = [];
     foreach ($this->backend as $key => $value) {
         $actualEntries[] = $key;
     }
     $this->assertCount(9, $actualEntries);
 }
コード例 #2
0
 /**
  * @test
  */
 public function findIdentifiersByTagInvokesRedis()
 {
     $this->redis->expects($this->once())->method('sMembers')->with('Foo_Cache:tag:some_tag')->will($this->returnValue(['entry_1', 'entry_2']));
     $this->assertEquals(['entry_1', 'entry_2'], $this->backend->findIdentifiersByTag('some_tag'));
 }