/** * Give (if possible) an extra lifetime to the given cache id * * @param string $id cache id * @param int $extraLifetime * @return boolean true if ok */ public function touch($id, $extraLifetime) { list($inf) = $this->_redis->hGet(self::PREFIX_KEY . $id, self::FIELD_INF); if ($inf === '0') { $expireAt = time() + $this->_redis->ttl(self::PREFIX_KEY . $id) + $extraLifetime; return (bool) $this->_redis->expireAt(self::PREFIX_KEY . $id, $expireAt); } return false; }
/** * 设置过期时间-timestamp格式 * @param string $id * @param timestamp $expireTimestamp * @return mixed */ public function expireAt($id, $expireTimestamp) { $key = $this->_getKeyName($id); return $this->_client->expireAt($key, $expireTimestamp); }