这是我从互联网上下载来测试 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