Sokil\Mongo\Cache::deleteMatchingAnyTag PHP Method

deleteMatchingAnyTag() public method

Delete documents by tag Document deletes if it contains any of passed tags
public deleteMatchingAnyTag ( array $tags )
$tags array
    public function deleteMatchingAnyTag(array $tags)
    {
        $this->collection->deleteDocuments(function (\Sokil\Mongo\Expression $e) use($tags) {
            return $e->whereIn(Cache::FIELD_NAME_TAGS, $tags);
        });
        return $this;
    }

Usage Example

Example #1
0
 public function testDeleteMatchingAnyTag()
 {
     $this->cache->setNeverExpired('php', 'PHP: Hypertext Processor', array('language', 'interpretable'))->setNeverExpired('c', 'C', array('language', 'compileable'));
     $this->assertEquals(2, count($this->cache));
     $this->cache->deleteMatchingAnyTag(array('compileable', 'elephant'));
     $this->assertEquals(1, count($this->cache));
     $this->assertTrue($this->cache->has('php'));
 }