/** * Cache provider. */ public function cacheProvider() { $cache = new ApcCache(); if (!$cache->available()) { return; } // flush apc for each run $cache->flush(); return array(array($cache)); }
/** * Test throttle. */ public function testThrottle() { $gc = new ApcGC(array('trigger_percent' => 100, 'grace_period' => 1, 'throttle' => 3)); $cache = new ApcCache(1, $gc); // will trigger the initial run $cache->save('foo', 'bar'); // throttled $this->assertNull($gc->run()); // force $this->assertTrue($gc->run(true)); // throttled $this->assertNull($gc->run()); // wait for throttle sleep(4); $this->assertTrue($gc->run()); }