diff --git a/library/think/cache/driver/Redis.php b/library/think/cache/driver/Redis.php index 9450aa70..f324957d 100644 --- a/library/think/cache/driver/Redis.php +++ b/library/think/cache/driver/Redis.php @@ -27,7 +27,7 @@ class Redis 'port' => 6379, 'password' => '', 'timeout' => false, - 'expire' => 0, + 'expire' => false, 'persistent' => false, 'length' => 0, ]; diff --git a/tests/thinkphp/library/think/cache/driver/redisTest.php b/tests/thinkphp/library/think/cache/driver/redisTest.php new file mode 100644 index 00000000..29a6e301 --- /dev/null +++ b/tests/thinkphp/library/think/cache/driver/redisTest.php @@ -0,0 +1,53 @@ + +// +---------------------------------------------------------------------- + +/** + * Redis缓存驱动测试 + * @author 7IN0SAN9 + */ + +namespace tests\thinkphp\library\think\cache\driver; + +class redisTest extends cacheTestCase +{ + private $_cacheInstance = null; + + protected function setUp() + { + \think\Cache::connect(array('type' => 'redis', 'expire' => 2)); + } + + protected function getCacheInstance() + { + if (!extension_loaded("redis")) { + $this->markTestSkipped("Redis没有安装,已跳过测试!"); + } + if (null === $this->_cacheInstance) { + $this->_cacheInstance = new \think\cache\driver\Redis(); + } + return $this->_cacheInstance; + } + + public function testGet() + { + $cache = $this->prepare(); + $this->assertEquals('string_test', $cache->get('string_test')); + $this->assertEquals(11, $cache->get('number_test')); + } + + public function testStoreSpecialValues() + { + } + + public function testExpire() + { + } +}