Sokil\Mongo\Cache::deleteNotMatchingTag PHP Method

deleteNotMatchingTag() public method

Delete documents by tag
public deleteNotMatchingTag ( $tag )
    public function deleteNotMatchingTag($tag)
    {
        $this->collection->deleteDocuments(function (\Sokil\Mongo\Expression $e) use($tag) {
            return $e->whereNotEqual(Cache::FIELD_NAME_TAGS, $tag);
        });
        return $this;
    }

Usage Example

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