redis驱动添加handler方法,暴露对象以调用高级方法

This commit is contained in:
尘缘
2016-05-06 17:20:48 +08:00
parent 336b0908a6
commit 63fde0a6fc
2 changed files with 21 additions and 0 deletions

View File

@@ -115,4 +115,14 @@ class Redis
return $this->handler->flushDB();
}
/**
* 返回句柄对象,可执行其它高级方法
*
* @access public
* @return object
*/
public function handler()
{
return $this->handler;
}
}

View File

@@ -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()