Esempio n. 1
0
 public function get(UnitTester $I)
 {
     $I->wantTo('Get data by using Redis as cache backend');
     $key = '_PHCR' . 'data-get';
     $data = [uniqid(), gethostname(), microtime(), get_include_path(), time()];
     $cache = new Redis(new Data(['lifetime' => 20]), ['host' => TEST_RS_HOST, 'port' => TEST_RS_PORT]);
     $I->haveInRedis('string', $key, serialize($data));
     $I->assertEquals($data, $cache->get('data-get'));
     $I->assertNull($cache->get($key));
     $data = 'sure, nothing interesting';
     $I->haveInRedis('string', $key, serialize($data));
     $I->assertEquals($data, $cache->get('data-get'));
     $I->assertNull($cache->get($key));
 }
Esempio n. 2
0
 /**
  * Returns a cached content
  *
  * @param string $keyName
  * @param int $lifetime
  * @return mixed
  */
 public function get($keyName, $lifetime = null)
 {
     if ($this->cache_status) {
         return $this->cache->get($keyName, $lifetime);
     } else {
         return null;
     }
 }