首页 > redis-php set失败

redis-php set失败

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Server is running: " . $redis->ping();

运行后输出:Server is running: +PONG

这说明运行成功了吗?

如果成功了

$redis->set("tutorial-name", "Redis tutorial");

我set个key一直返回false

查了资料没找到原因,log文件也没发现


我也碰到的是set返回false,代码里面测试是没有具体提示信息的,后来就去linux服务器上面测试redis到底是否有效,测试结果提示set确实有问题,提示(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. 然后就百度或者google了,按照网上的做法运行config set stop-writes-on-bgsave-error no 或者修改sysctl vm.overcommit_memory=1(都可以试试)就ok了


键为何中间有- 你键弄成简单点的,比如a


你直接写命令看看这个key能放进去吗?


貌似没用用 redis->select($db); 选择数据库吧。


pong表示链接成功,set不了请查看日志

【热门文章】
【热门文章】