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

This commit is contained in:
尘缘
2016-05-06 17:28:34 +08:00
parent 63fde0a6fc
commit e2828d3ff6
2 changed files with 51 additions and 36 deletions

View File

@@ -9,13 +9,12 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace tests\thinkphp\library\think\cache\driver;
/**
* Redisd缓存驱动测试
* @author 尘缘 <130775@qq.com>
*/
namespace tests\thinkphp\library\think\cache\driver;
class redisdTest extends cacheTestCase
{
private $_cacheInstance = null;
@@ -31,7 +30,7 @@ class redisdTest extends cacheTestCase
protected function getCacheInstance()
{
if (null === $this->_cacheInstance) {
$this->_cacheInstance = new \think\cache\driver\Redisd(['length' => 3]);
$this->_cacheInstance = new \think\cache\driver\Redisd();
}
return $this->_cacheInstance;
}
@@ -47,6 +46,20 @@ class redisdTest extends cacheTestCase
public function testStoreSpecialValues()
{
$redis = new \think\cache\driver\Redisd(['length' => 3]);
$redis->master(true);
$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);
$redis->master(true)->hset('hash', 'key', 'value');
$value = $redis->master(false)->hget('hash', 'key');
$this->assertEquals('value', $value);
}
public function testExpire()