Exemplo n.º 1
0
 /**
  * Starts a cache. The keyName allows to identify the created fragment
  *
  * @param   int|string $keyName
  * @param   integer $lifetime
  * @return  mixed
  */
 public function start($keyName, $lifetime = null)
 {
     return $this->cache->start($keyName, $lifetime);
 }
Exemplo n.º 2
0
 public function output(UnitTester $I)
 {
     $I->wantTo('Cache output fragments by using Redis as cache backend');
     $time = date('H:i:s');
     $cache = new Redis(new Output(['lifetime' => 2]), ['host' => TEST_RS_HOST, 'port' => TEST_RS_PORT]);
     ob_start();
     // First time cache
     $content = $cache->start('test-output');
     $I->assertNull($content);
     echo $time;
     $cache->save(null, null, null, true);
     $obContent = ob_get_contents();
     ob_end_clean();
     $I->assertEquals($time, $obContent);
     $I->seeInRedis('_PHCR' . 'test-output', $time);
     // Expect same cache
     $content = $cache->start('test-output');
     $I->assertNotNull($content);
     $I->assertEquals($time, $obContent);
     $I->seeInRedis('_PHCR' . 'test-output', $time);
     sleep(2);
     $content = $cache->start('test-output');
     $I->assertNull($content);
     $I->dontSeeInRedis('_PHCR' . 'test-output');
 }