mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
redis驱动添加handler方法,暴露对象以调用高级方法
This commit is contained in:
10
library/think/cache/driver/Redis.php
vendored
10
library/think/cache/driver/Redis.php
vendored
@@ -115,4 +115,14 @@ class Redis
|
|||||||
return $this->handler->flushDB();
|
return $this->handler->flushDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回句柄对象,可执行其它高级方法
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function handler()
|
||||||
|
{
|
||||||
|
return $this->handler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,17 @@ class redisTest extends cacheTestCase
|
|||||||
|
|
||||||
public function testStoreSpecialValues()
|
public function testStoreSpecialValues()
|
||||||
{
|
{
|
||||||
|
$redis = new \think\cache\driver\Redis(['length' => 3]);
|
||||||
|
$redis->set('key', 'value');
|
||||||
|
$redis->get('key');
|
||||||
|
|
||||||
|
$redis->handler()->setnx('key', 'value');
|
||||||
|
$value = $redis->handler()->get('key');
|
||||||
|
$this->assertEquals('value', $value);
|
||||||
|
|
||||||
|
$redis->handler()->hset('hash', 'key', 'value');
|
||||||
|
$value = $redis->handler()->hget('hash', 'key');
|
||||||
|
$this->assertEquals('value', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExpire()
|
public function testExpire()
|
||||||
|
|||||||
Reference in New Issue
Block a user