/** * Test run. */ public function testRun() { $gc = new ApcGC(array('trigger_percent' => 100, 'grace_period' => 1)); // use gc and set default ttl to 1 second $cache = new ApcCache(1, $gc); // add entry $cache->save('foo', 'bar'); $stats = $cache->getStats(); $this->assertEquals(1, $stats['size']); // wait to expire sleep(4); // get stats for later comparison $before = $cache->getStats(); $this->assertEquals(1, $before['size']); // add another entry (no gc, though) $cache->save('ding', 'dong', 30); $stats = $cache->getStats(); $this->assertEquals(2, $stats['size']); // force gc $gc->run(true); // should be 1 - ding $after = $cache->getStats(); $this->assertEquals(1, $after['size']); $this->assertFalse($cache->contains('foo')); $this->assertTrue($cache->contains('ding')); }