最近想在5.6版本的开发环境装一下redis的扩展,结果找了半天都是失效链接,特此做下备份
https://pecl.php.net/package/redis/2.2.7/windows
然后,把php_redis.dll放到php的ext文件夹下
最后在php.ini加上
extension=php_redis.dll
重启环境运行下面代码,前提是已启动redis
$redis = new Redis(); $redis->connect(‘127.0.0.1‘, 6379); echo "Connection to server sucessfully"; //查看服务是否运行 echo "Server is running: " . $redis->ping();
执行脚本,输出结果为:
Connection to server sucessfully Server is running: PONG
//连接本地的 Redis 服务 $redis = new Redis(); $redis->connect(‘127.0.0.1‘, 6379); echo "Connection to server sucessfully"; //设置 redis 字符串数据 $redis->set("tutorial-name", "Redis tutorial"); // 获取存储的数据并输出 echo "Stored string in redis:: " . $redis->get("tutorial-name");
执行脚本,输出结果为:
Connection to server sucessfully Stored string in redis:: Redis tutorial
时间: 2024-10-12 16:31:38