3

这是我从互联网上下载来测试 Redis 的基本代码。设置或获取时,我什么也得不到。我怀疑我的 php 配置有问题,但不确定如何找出问题所在。我也尝试过使用 predis 作为客户端,它的反应方式也相同。

$connected= $redis->connect('localhost', 6379); //works

if(!$connected) {
    // some other code to handle connection problem
    die( "Cannot connect to redis server.\n" );
}

$redis->set('somekey', 'some value');  // fails

echo $redis->get('somekey'); //fails
4

1 回答 1

0

检查 phpinfo() 函数是否在列表中显示 redis 客户端。

如果 requirepass 设置为某个值,还要检查 redis.conf,如果是,则必须使用这些凭据连接 redis。

于 2014-06-03T19:28:32.837 回答