/** * @test Implementation */ public function collectGarbageRemovesExpiredIdentifierFromTagsToIdentifierSet() { $this->setUpBackend(); $this->setUpRedis(); $identifier = 'identifier' . uniqid(); $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2')); $this->backend->set($identifier . 'B', 'data', array('tag2')); $this->redis->delete('identData:' . $identifier . 'A'); $this->backend->collectGarbage(); $expectedResult = array(array(), array($identifier . 'B')); $actualResult = array($this->redis->sMembers('tagIdents:tag1'), $this->redis->sMembers('tagIdents:tag2')); $this->assertSame($expectedResult, $actualResult); }
/** * @test */ public function removeRemovesEntryFromCache() { for ($i = 0; $i < 10; $i++) { $this->backend->set('entry_' . $i, 'foo', array('tag1')); } $this->assertCount(10, $this->backend->findIdentifiersByTag('tag1')); $this->assertEquals('foo', $this->backend->get('entry_1')); $actualEntries = array(); 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 = array(); foreach ($this->backend as $key => $value) { $actualEntries[] = $key; } $this->assertCount(9, $actualEntries); }
/** * @test */ public function hasInvokesRedis() { $this->redis->expects($this->once())->method('exists')->with('Foo_Cache:entry:foo')->will($this->returnValue(TRUE)); $this->assertEquals(TRUE, $this->backend->has('foo')); }