From 63fde0a6fc858d7974ab392b7ba03d8b053ef638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=98=E7=BC=98?= Date: Fri, 6 May 2016 17:20:48 +0800 Subject: [PATCH] =?UTF-8?q?redis=E9=A9=B1=E5=8A=A8=E6=B7=BB=E5=8A=A0handle?= =?UTF-8?q?r=E6=96=B9=E6=B3=95=EF=BC=8C=E6=9A=B4=E9=9C=B2=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E4=BB=A5=E8=B0=83=E7=94=A8=E9=AB=98=E7=BA=A7=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/Redis.php | 10 ++++++++++ .../thinkphp/library/think/cache/driver/redisTest.php | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/library/think/cache/driver/Redis.php b/library/think/cache/driver/Redis.php index 6ae0f1da..e31d38f7 100644 --- a/library/think/cache/driver/Redis.php +++ b/library/think/cache/driver/Redis.php @@ -115,4 +115,14 @@ class Redis return $this->handler->flushDB(); } + /** + * 返回句柄对象,可执行其它高级方法 + * + * @access public + * @return object + */ + public function handler() + { + return $this->handler; + } } diff --git a/tests/thinkphp/library/think/cache/driver/redisTest.php b/tests/thinkphp/library/think/cache/driver/redisTest.php index 4f0c4a4c..c55ab828 100644 --- a/tests/thinkphp/library/think/cache/driver/redisTest.php +++ b/tests/thinkphp/library/think/cache/driver/redisTest.php @@ -47,6 +47,17 @@ class redisTest extends cacheTestCase 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()