...
|
...
|
@@ -68,7 +68,7 @@ class CacheRedis extends Root implements CacheInterface |
|
|
* @return Redis
|
|
|
* @throws DebugException
|
|
|
*/
|
|
|
private function init()
|
|
|
final private function init()
|
|
|
{
|
|
|
if (isset($this->redisInstances[$this->persistentID])) {
|
|
|
$redis = $this->redisInstances[$this->persistentID];
|
...
|
...
|
@@ -164,8 +164,8 @@ class CacheRedis extends Root implements CacheInterface |
|
|
|
|
|
/**
|
|
|
* 设置key-value并设置过期时间
|
|
|
* @param $key
|
|
|
* @param $val
|
|
|
* @param string $key
|
|
|
* @param string $val
|
|
|
* @param int $timeout 过期时间,单位:秒
|
|
|
* @return bool
|
|
|
* @throws DebugException
|
...
|
...
|
@@ -190,24 +190,24 @@ class CacheRedis extends Root implements CacheInterface |
|
|
|
|
|
/**
|
|
|
* 增量
|
|
|
* @param $key
|
|
|
* @param int $value
|
|
|
* @param string $key
|
|
|
* @param string $value
|
|
|
* @throws DebugException
|
|
|
*/
|
|
|
public function increment($key, $value = 1)
|
|
|
{
|
|
|
$this->init()->incrBy((string)$key, (int)$value);
|
|
|
return $this->init()->incrBy((string)$key, (int)$value);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 减量
|
|
|
* @param $key
|
|
|
* @param string $key
|
|
|
* @param int $value
|
|
|
* @throws DebugException
|
|
|
*/
|
|
|
public function decrement($key, $value = 1)
|
|
|
{
|
|
|
$this->init()->decrBy((string)$key, (int)$value);
|
|
|
return $this->init()->decrBy((string)$key, (int)$value);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -237,45 +237,74 @@ class CacheRedis extends Root implements CacheInterface |
|
|
|
|
|
/**
|
|
|
* 向list左压入
|
|
|
* @param $key
|
|
|
* @param $value
|
|
|
* @param string $key
|
|
|
* @param string $value
|
|
|
* @throws DebugException
|
|
|
*/
|
|
|
public function lpush($key, $value)
|
|
|
{
|
|
|
$this->init()->lPush((string)$key, $value);
|
|
|
return $this->init()->lPush((string)$key, $value);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 从list左弹出
|
|
|
* @param $key
|
|
|
* @param string $key
|
|
|
* @throws DebugException
|
|
|
*/
|
|
|
public function lpop($key)
|
|
|
{
|
|
|
$this->init()->lPop((string)$key);
|
|
|
return $this->init()->lPop((string)$key);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 向list右压入
|
|
|
* @param $key
|
|
|
* @param $value
|
|
|
* @param string $key
|
|
|
* @param string $value
|
|
|
* @throws DebugException
|
|
|
*/
|
|
|
public function rpush($key, $value)
|
|
|
{
|
|
|
$this->init()->rPush((string)$key);
|
|
|
return $this->init()->rPush((string)$key, $value);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 从list右弹出
|
|
|
* @param $key
|
|
|
* @param string $key
|
|
|
* @throws DebugException
|
|
|
*/
|
|
|
public function rpop($key)
|
|
|
{
|
|
|
$this->init()->rPop((string)$key);
|
|
|
return $this->init()->rPop((string)$key);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 检查一个key是否存在
|
|
|
* @param string $key
|
|
|
* @return int
|
|
|
*/
|
|
|
public function exists($key)
|
|
|
{
|
|
|
return $this->init()->exists((string)$key);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置过期时间
|
|
|
* @param string $key
|
|
|
* @param int $second
|
|
|
* @return int
|
|
|
*/
|
|
|
public function expire($key, $second)
|
|
|
{
|
|
|
return $this->init()->expire((string)$key, (int)$second);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function mget()
|
|
|
{
|
|
|
return $this->init()->mget();
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|