这是我从互联网上测试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
答案 0 :(得分:0)
检查phpinfo()函数是否在列表中显示redis客户端。
如果requirepass设置为某个值,也请检查redis.conf,如果是,则必须使用这些凭据连接redis。