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 testDataRedisCache()
 {
     $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));
     $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");
     $this->assertTrue($cache->delete('test-data'));
     $cache->save('a', 1);
     $cache->save('long-key', 'long-val');
     $cache->save('bcd', 3);
     $keys = $cache->queryKeys();
     sort($keys);
     $this->assertEquals($keys, array('a', 'bcd', 'decrement', 'increment', 'long-key'));
     $this->assertEquals($cache->queryKeys('long'), array('long-key'));
     $this->assertTrue($cache->delete('a'));
     $this->assertTrue($cache->delete('long-key'));
     $this->assertTrue($cache->delete('bcd'));
 }