Wamp 以及 Linux 下使用 Redis

数据表中数据达到万条以及访问量增高,来使用 redis 来提高网站高可用访问。

Wamp下的使用:

1:寻找对应版本并安装 redis 和 igbinary

https://github.com/dmajkic/redis/downloads

2:使用

进入对应位数目录下执行:

#开启 redis
redis-server.exe redis.conf 

#开启新窗口,还在原来的redis目录下执行连接:
redis-cli.exe -h 127.0.0.1 -p 6379 

#输出以下信息表示成功
λ redis-cli.exe -h 127.0.0.1 -p 6379
redis 127.0.0.1:6379> set test "new Redis"
OK

#添加测试
#增加test值
set test "new Redis"
#读取
get test

3:设置 php 的 redis 扩展

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

Architecture 架构 (我的是x64)

ThreadSafe 线程类型enable表示开启。我们需要找的php扩展就是 php7.0- VC14 ts-x64

注意 php 版本 和 对应 ts 及 Architecture 版本

下载地址:

https://windows.php.net/downloads/pecl/releases/redis/

https://windows.php.net/downloads/pecl/releases/igbinary/

 下载后放到php.ini中,按顺序放,然后重启服务器,在查看 phpinfo,如图安装成功

#添加 扩展的时候一定要
extension=php_igbinary.dll
extension=php_redis.dll
#这个顺序

4:使用可视化工具,请搜索 Redis Desktop Manager 自行下载

5:框架中测试,我在 thinkphp5.1 中测试

$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//查看服务是否运行
echo "Server is running: " . $redis->ping().'<br>';

猜你喜欢

转载自blog.csdn.net/myarche/article/details/88115077