Exemplo n.º 1
0
 /**
  * Stores cached content
  *
  * @param string $keyName
  * @param string $content
  * @param int $lifetime
  * @param boolean $stopBuffer
  */
 public function set($keyName = null, $content = null, $lifetime = null, $stopBuffer = null)
 {
     if ($this->cache_status) {
         $this->cache->save($keyName, $content, $lifetime, $stopBuffer);
     }
 }
Exemplo n.º 2
0
 public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null)
 {
     parent::__construct($frontend, $options);
 }
Exemplo n.º 3
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');
 }