<?php
/**
* Redis 操作类
* 可以使用redis的所有数据类型,而tp5仅可使用string类型+
* 字符串(String) 哈希(Hash) 列表(List) 集合(Set) 有序集合(sorted set)
* Created by PhpStorm.
* User: Administrator
* Date: 2020/10/21
* Time: 10:45
*/
namespace app\common;
use think\Config;
class Redis extends \Redis
{
public function __construct()
{
$host = Config::get('redis')['host'];
$password = Config::get('redis')['password'];
$this->connect($host);
if($password){
$this->auth($password);
}
}
public function connect($host, $port = 6379, $timeout = 0.0, $reserved = null, $retry_interval = 0, $read_timeout = 0.0)
{
parent::connect($host, $port, $timeout, $reserved, $retry_interval, $read_timeout); // TODO: Change the autogenerated stub
}
public function auth($password)
{
parent::auth($password); // TODO: Change the autogenerated stub
}
}
/**
* redis 配置文件
* Created by PhpStorm.
* User: Administrator
* Date: 2020/10/21
* Time: 10:52
*/
return [
'host' => '127.0.0.1',
'port' => 6379,
'password' => 'niu123456',
'select' => 0,
'timeout' => 0,
'expire' => 0,
'persistent' => false,
'prefix' => '',
];