think\cache\driver\Redis::get PHP Method

get() public method

读取缓存
public get ( string $name, mixed $default = false ) : mixed
$name string 缓存变量名
$default mixed 默认值
return mixed
    public function get($name, $default = false)
    {
        $value = $this->handler->get($this->getCacheKey($name));
        if (is_null($value)) {
            return $default;
        }
        $jsonData = json_decode($value, true);
        // 检测是否为JSON数据 true 返回JSON解析数组, false返回源数据 byron sampson<[email protected]>
        return null === $jsonData ? $value : $jsonData;
    }

Usage Example

 public function test()
 {
     $redis = new Redis();
     // $redis->connect('127.0.0.1',6379);
     $redis->set('test', 'hello world!');
     echo $redis->get("test");
 }
All Usage Examples Of think\cache\driver\Redis::get