Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function set($key, $data, $ttl = 0)
 {
     if ($ttl > 0) {
         return $this->redis->setex($key, (int) $ttl, $data);
     }
     return $this->redis->set($key, $data);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function storeData($key, $data, $expiration)
 {
     $store = serialize(array('data' => $data, 'expiration' => $expiration));
     if (is_null($expiration)) {
         return $this->redis->set($this->makeKeyString($key), $store);
     } else {
         $ttl = $expiration - time();
         // Prevent us from even passing a negative ttl'd item to redis,
         // since it will just round up to zero and cache forever.
         if ($ttl < 1) {
             return true;
         }
         return $this->redis->setex($this->makeKeyString($key), $ttl, $store);
     }
 }