Exemple #1
0
 public function testDataRedisSelect()
 {
     $redis = $this->_prepareRedis();
     if (!$redis) {
         return false;
     }
     $redis->delete('test-data');
     $frontCache = new Phalcon\Cache\Frontend\Data();
     $cache = new Phalcon\Cache\Backend\Redis($frontCache, array('host' => 'localhost', 'port' => 6379, 'index' => 1));
     $data = array(1, 2, 3, 4, 5);
     $cache->save('test-data', $data);
     $cachedContent = $cache->get('test-data');
     $this->assertEquals($cachedContent, $data);
     $cache->save('test-data', "sure, nothing interesting");
     $cachedContent = $cache->get('test-data');
     $this->assertEquals($cachedContent, "sure, nothing interesting");
     $data = $redis->get('_PHCR' . 'test-data');
     $this->assertFalse($data);
     $redis->select(1);
     $data = $redis->get('_PHCR' . 'test-data');
     $this->assertEquals($data, serialize("sure, nothing interesting"));
     $this->assertTrue($cache->delete('test-data'));
 }
Exemple #2
0
 public function testCacheRedisFlush()
 {
     $frontCache = new Phalcon\Cache\Frontend\Data(array('lifetime' => 10));
     $redis = $this->_prepareRedis();
     if (!$redis) {
         return false;
     }
     $frontCache = new Phalcon\Cache\Frontend\Data();
     $cache = new Phalcon\Cache\Backend\Redis($frontCache, array('host' => 'localhost', 'port' => 6379));
     $cache->save('data', "1");
     $cache->save('data2', "2");
     $this->assertTrue($cache->exists('data'));
     $this->assertTrue($cache->exists('data2'));
     $this->assertTrue($cache->flush());
     $this->assertFalse($cache->exists('data'));
     $this->assertFalse($cache->exists('data2'));
 }