下载安装,参考:https://github.com/yosa/predis
引入predis,例如:
require 'vendor/predis/predis/autoload.php'; //以实际路径为准
Predis\Autoloader::register();
使用:
$redis = new Predis\Client( [ 'host' => $redisInfo['path'], //服务器地址 'port' => $redisInfo['port'], //端口 'database' => $redisInfo['select'], //连接数据库 'password' => $redisInfo['auth'], //密码 ] ); $redis->set("test", 11); var_dump($redis->get("test")); //打印11