您的位置 首页 php

干货!详解PHP 使用 Redis

安装

开始在 PHP 中使用 Redis 前, 我们需要确保已经安装了 redis 服务及 PHP redis 驱动,且你的机器上能正常使用 PHP。


PHP安装redis扩展

以下操作需要在下载的 phpredis 目录中完成:

修改php. ini 文件

vi /usr/local/php/lib/php.ini
 

增加如下内容:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
 

安装完成后重启php-fpm 或 apache。查看phpinfo信息,就能看到redis扩展。


连接到 redis 服务

执行脚本,输出结果为:

Connection to server sucessfully
Server is running: PONG
 

Redis PHP String( 字符串 ) 实例

执行脚本,输出结果为:

Connection to server sucessfully
Stored string in redis:: Redis tutorial
 

Redis PHP List(列表) 实例

执行脚本,输出结果为:

Redis PHP Keys 实例

执行脚本,输出结果为:


小编每天都会分享这方面的干货,感兴趣的朋友走一波关注哩~

文章来源:智云一二三科技

文章标题:干货!详解PHP 使用 Redis

文章地址:https://www.zhihuclub.com/149661.shtml

关于作者: 智云科技

热门文章

网站地图