您的位置 首页 php

php设置redis扩展,你值得拥有

redis 安装(window安装)

首先下载redis,打开一个 cmd 窗口 使用cd命令切换目录到 C:\redis 运行 redis-server.exe redis.windows.conf 。

这时候另启一个cmd窗口,原来的不要关闭,不然就无法访问服务端了。

切换到redis目录下运行 redis-cli.exe -h 127.0.0.1 -p 6379 。

设置键值对 set myKey abc

取出键值对 get myKey

设置php的redis扩展

先查看phpinfo()

Compile可以看到windows里的编译版本(我的是VC9)

Architecture 架构 (我的是x86)

ThreadSafe 线程 类型enable表示开启。我们需要找的PHP扩展就是php 5.3 VC9ts-x86

将下载的php_redis. dll ,php_igbinary.dll放在php扩展目录中(ext),并修改配置文件php. ini

添加 扩展的时候一定要

extension=php_igbinary.dll

extension=php_redis.dll

这个顺序

重新启动服务,查看phpinfo(),下面表示成功

thinkphp 框架看redis扩展是否成功

db.php 配置文件加上

‘REDIS_HOST’=>’127.0.0.1’,

‘REDIS_PORT’=>6379,

‘REDIS_TIMEOUT’=>’300’,

‘REDIS_AUTH’=>123456,

‘REDIS_DB_PREFIX’=>”,

控制器输出

$redis = new \Redis();

$redis-> connect (‘127.0.0.1’,6379);

$redis->set(‘ test ‘,’hello world!’);

echo $redis->get(“test”);

输出的 hello world 就表示设置扩展成功

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

文章标题:php设置redis扩展,你值得拥有

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

关于作者: 智云科技

热门文章

网站地图