public function getRedis()
{
$redis = new \Redis();
$redis->connect(env("REDIS_MASTER",'127.0.0.1'),6379);
$redis->auth(env('REDIS_AUTH','123456'));
return $redis;
}
複製代碼
public function getRedis()
{
$redis = new \Redis();
$redis->connect(env("REDIS_MASTER",'127.0.0.1'),6379);
$auth = env('REDIS_ONLY_READ_USER').":".env('REDIS_ONLY_READ_PWD');
$redis->auth($auth);
return $redis;
}
複製代碼
$this->getRedis()->set('name','WXiangQian');
$name = $this->getRedis()->get('name');
echo $name; // WXiangQian
複製代碼
Redis基礎篇——Redis安裝redis
Redis基礎篇——介紹以及瞭解bash
Redis基礎篇——基本用法post