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?

duan01203
duan01203 整个Redis_Module发布了@misterion
接近 5 年之前 回复
doufu1970
doufu1970 看起来你在这个模块中遇到了麻烦。你可以通过你的set/get实现吗?
接近 5 年之前 回复
duanhe1903
duanhe1903 RedisModule是一个由我自己的类Redis模块编写的辅助类,它包含连接和info()get()set()@misterion
接近 5 年之前 回复
dragon0023
dragon0023 什么是Redis_Module是你的代码?phpredis扩展不提供这种类的PHP。
接近 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐