php 如何连接有密码的Redis服务器

WBOY
Release: 2016-06-06 20:10:47
Original
1276 people have browsed it

//一般使用下面代码连接Redis

<code>$redis = new redis();  
$result = $redis->connect('127.0.0.1', 6379);  </code>
Copy after login
Copy after login

但配置密码后的Redis呢,怎么连接

回复内容:

//一般使用下面代码连接Redis

<code>$redis = new redis();  
$result = $redis->connect('127.0.0.1', 6379);  </code>
Copy after login
Copy after login

但配置密码后的Redis呢,怎么连接

<code>  //实例化  
  $redis = new Redis();  
  //连接服务器  
  $redis->connect("localhost");  
  //授权  
  $redis->auth("passwd");  
  //相关操作  
  $redis->set("name","father");  
  $data = $redis->key("*");  
  var_dump($data);  </code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!