/** * @param $key * @param $ttl_left * @return mixed|string */ protected function read_value($key, &$ttl_left = -1) { $value = $this->redis->get($this->prefix . $key); if ($this->redis->Exists($this->serialize_key_prefix . $key)) { $value = unserialize($value); } if ($ttl_left !== -1) { $ttl_left = $this->redis->TTL($this->prefix . $key); if ($ttl_left < 0) { $ttl_left = 0; } } return $value; }
/** * Read data from memory storage * * @param string|array $key (string or array of string keys) * @param mixed $ttl_left = (ttl - time()) of key. Use to exclude dog-pile effect, with lock/unlock_key methods. * @return mixed */ public function read($key, &$ttl_left = -1) { $r = unserialize($this->redis->get($this->prefix . $key)); if ($r === false) { return false; } if ($ttl_left !== -1) { $ttl_left = $this->redis->TTL($this->prefix . $key); if ($ttl_left < 1) { $ttl_left = self::max_ttl; } } return $r; }