Sokil\Mongo\Cache::deleteNotMatchingAnyTag PHP Method

deleteNotMatchingAnyTag() public method

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

Usage Example

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