安装php连接redis cluster扩展
1、下载群集扩展
wgethttps://github.com/nrk/predis/archive/v1.0.zipunzipv1.0cp-Rfpredis-1.0/u01/html/predis注:/u01/html为系统目录
<?php//连接本地的Redis服务require'predis/autoload.php';$parameters=['tcp://192.168.1.231:7003','tcp://192.168.1.231:7003','tcp://192.168.1.231:7005'];$options=['cluster'=>'redis'];$redis=newPredis\Client($parameters,$options);$x=rand(10,100);//设置redis字符串数据$redis->set("y".$x,"tank".$x*2);//获取存储的数据并输出$result=$redis->get("y".$x);//输出结果echo$result;?>
注:Predis只是几个PHP文件,不需要安装到PHP扩展中,只需要把文件拷到php能调用的目录就行
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。