dongnong7524 2015-11-10 09:33
浏览 44

phpredis无法设置值

I connected the slave redis, what a silly mistake -_-!!!

The learn is that we should always check server status before jumping into client code .

I'm trying to use redis in a php app, as google result, I choose phpredis. I established the connection, successfully got redis info by $this->_redis->info(), but failed to set any value. here are some software info:

php : 5.5.19 x64 thread safe

framework : CodeIgniter(sorry I don't know where to get version info)

redis : 2.8.15

phpredis : php_redis-2.2.7-5.5-ts-vc11-x64

And a helper class contains connection configuration and functions

class Redis_Module{
    private $_redis;
    function __construct(){     
        $this->ci = & get_instance();
        $redis_connection_array = $this->ci->config->item('redis_connection_array');
        $this->_redis = new Redis();
        $this->_redis->connect($redis_connection_array['host'],$redis_connection_array['port']);
        $this->_redis->auth($redis_connection_array['password']);
    }
    function info(){
        return $this->_redis->info();
    }
    function get($key){
        return $this->_redis->get($key);
    }
    function set($key, $value){
        return $this->_redis->set($key, $value);
    }
}

When I call these 3 functions, I can successfully get redis info, but both set('foo', 'bar') and get('foo') functions return false, especially get('an_existing_key') returns correct info cached in redis.

$redis_client = new Redis_Module();
$msg1 = $redis_client->set('foo', 'bar');
$msg2 = $redis_client->get("foo");
$msg3 = $redis_client->get("an_existing_key");
$msg4 = $redis_client->info();

I'm not familiar with php so am I missing any critical config or anything else?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog