Ejemplo n.º 1
0
 /**
  * Cache provider.
  */
 public function cacheProvider()
 {
     $cache = new ApcCache();
     if (!$cache->available()) {
         return;
     }
     // flush apc for each run
     $cache->flush();
     return array(array($cache));
 }
Ejemplo n.º 2
0
 /**
  * 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());
 }