bool xRedisClient::strlen(const RedisDBIdx& dbi,const string& key, int& length) {
    int64_t intval = 0;
    SETDEFAULTIOTYPE(SLAVE);
    bool bRet = command_integer(dbi, intval, "STRLEN %s", key.c_str());
    length = (int)intval;
    return bRet;
}
bool xRedisClient::setrange(const RedisDBIdx& dbi,const string& key,  int offset, const string& value, int& length) {
    int64_t intval = 0;
    SETDEFAULTIOTYPE(MASTER);
    bool bRet = command_integer(dbi, intval, "setrange %s %d %s", key.c_str(), offset, value.c_str());
    length = (int)intval;
    return bRet;
}
bool xRedisClient::bitpos(const RedisDBIdx& dbi, const string& key, int bit, int64_t& pos, int start, int end) {
    SETDEFAULTIOTYPE(SLAVE);
    if ( (start!=0)||(end!=0) ) {
        return command_integer(dbi, pos, "BITPOS %s %d %d %d", key.c_str(), bit, start, end);
    } 
    return command_integer(dbi, pos, "BITPOS %s %d", key.c_str(), bit);
}
Exemplo n.º 4
0
bool xRedisClient::spop(const RedisDBIdx& dbi,  const KEY& key, VALUE& member) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_string(dbi, member, "SPOP %s", key.c_str());
}
Exemplo n.º 5
0
bool xRedisClient::rpushx(const RedisDBIdx& dbi,   const string& key, const string& value, int64_t& length) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_integer(dbi, length, "RPUSHX %s %s", key.c_str(), value.c_str());
}
 bool xRedisClient::zscore(const RedisDBIdx& dbi,  const string& key, const string &member, string& score ){
     if (0==key.length()) {
         return false;
     }
     SETDEFAULTIOTYPE(SLAVE);
     return command_string(dbi, score, "ZSCORE %s %s", key.c_str(), member.c_str());
 }
bool xRedisClient::mget(const DBIArray &vdbi,   const KEYS &  keys, ReplyData& vDdata) {
    bool bRet = false;
    size_t n = vdbi.size();
    if (n!=keys.size()) {
        return bRet;
    }
    
    DataItem item;
    DBIArray::const_iterator iter_dbi = vdbi.begin();
    KEYS::const_iterator iter_key = keys.begin();
    for (;iter_key!=keys.end();++iter_key, ++iter_dbi) {
        const RedisDBIdx& dbi = *iter_dbi;
        SETDEFAULTIOTYPE(SLAVE);
        const string &key = *iter_key;
        if (key.length()>0) {
            bool ret = command_string(*iter_dbi, item.str, "GET %s", key.c_str());
            if (!ret) {
                item.type = REDIS_REPLY_NIL;
                item.str  = "";
            } else {
                item.type = REDIS_REPLY_STRING;
                bRet = true;
            }
            vDdata.push_back(item);
        }
    }
    return bRet;
}
bool xRedisClient::getbit( const RedisDBIdx& dbi, const string& key, int& offset, int& bit ) {
    SETDEFAULTIOTYPE(SLAVE);
    int64_t intval = 0;
    bool bRet = command_integer(dbi, intval, "GETBIT %s %d", key.c_str(), offset);
    bit = (int)intval;
    return bRet;
}
Exemplo n.º 9
0
bool xRedisClient::lrange(const RedisDBIdx& dbi,    const string& key, int64_t start, int64_t end, ArrayReply& array) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(SLAVE);
	return command_array(dbi, array, "LRANGE %s %lld %lld", key.c_str(), start, end);
}
Exemplo n.º 10
0
bool xRedisClient::smembers(const RedisDBIdx& dbi,  const KEY& key, VALUES& vValue) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(SLAVE);
	return command_list(dbi, vValue, "SMEMBERS %s", key.c_str());
}
Exemplo n.º 11
0
bool xRedisClient::lrem(const RedisDBIdx& dbi, const string& key, int count, const string& value, int64_t num) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_integer(dbi, num, "LREM %s %d %s", key.c_str(), count, value.c_str());
}
bool xRedisClient::zremrangebyrank(const RedisDBIdx& dbi,  const string& key, int start, int stop, int64_t& count) {
    if (0==key.length()) {
        return false;
    }
    SETDEFAULTIOTYPE(MASTER);
    return command_integer(dbi, count, "ZREMRANGEBYRANK %s %d %d", key.c_str(), start, stop);
}
Exemplo n.º 13
0
bool xRedisClient::lset(const RedisDBIdx& dbi, const string& key, int index, const string& value) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_status(dbi, "LSET %s %d %s", key.c_str(), index, value.c_str());
}
bool xRedisClient::zincrby(const RedisDBIdx& dbi,  const string& key, const double &increment, const string& member, string& value ) {
    if (0==key.length()) {
        return false;
    }
    SETDEFAULTIOTYPE(MASTER);
    return command_string(dbi, value, "ZINCRBY %s %f %s", key.c_str(), increment, member.c_str());
}
Exemplo n.º 15
0
bool xRedisClient::rpoplpush(const RedisDBIdx& dbi,    const string& key_src, const string& key_dest, string& value) {
	if ((0 == key_src.length()) || (0 == key_dest.length())) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_string(dbi, value, "RPOPLPUSH %s %s", key_src.c_str(), key_dest.c_str());
}
bool xRedisClient::zscrad(const RedisDBIdx& dbi,     const string& key, int64_t& count){
    if (0==key.length()) {
        return false;
    }
    SETDEFAULTIOTYPE(SLAVE);
    return command_integer(dbi, count, "ZSCRAD %s", key.c_str());
}
Exemplo n.º 17
0
bool xRedisClient::ltrim(const RedisDBIdx& dbi, const string& key, int start, int end) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_status(dbi, "LTRIM %s %d %d", key.c_str(), start, end);
}
Exemplo n.º 18
0
bool xRedisClient::rpop(const RedisDBIdx& dbi,    const string& key, string& value) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_string(dbi, value, "RPOP %s", key.c_str());
}
 bool xRedisClient::zrevrank(const RedisDBIdx& dbi,  const string& key, const string &member, int64_t& rank){
     if (0==key.length()) {
         return false;
     }
     SETDEFAULTIOTYPE(SLAVE);
     return command_integer(dbi, rank, "ZREVRANK %s %s", key.c_str(), member.c_str());
 }
Exemplo n.º 20
0
bool xRedisClient::llen(const RedisDBIdx& dbi,    const string& key, int64_t& retval) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(SLAVE);
	return command_integer(dbi, retval, "LLEN %s", key.c_str());
}
Exemplo n.º 21
0
bool xRedisClient::smove(const RedisDBIdx& dbi,  const KEY& srckey, const KEY& deskey,  const VALUE& member) {
	if (0 == srckey.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_bool(dbi, "SMOVE %s", srckey.c_str(), deskey.c_str(), member.c_str());
}
Exemplo n.º 22
0
bool xRedisClient::lindex(const RedisDBIdx& dbi,    const string& key, int64_t index, VALUE& value) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(SLAVE);
	return command_string(dbi, value, "LINDEX %s %lld", key.c_str(), index);
}
bool xRedisClient::zrem(const RedisDBIdx& dbi,        const KEY& key, const VALUES& vmembers, int64_t &count) {
    VDATA vCmdData;
    vCmdData.push_back("ZREM");
    vCmdData.push_back(key);
    addparam(vCmdData, vmembers);
    SETDEFAULTIOTYPE(MASTER);
    return commandargv_integer(dbi, vCmdData, count);
}
Exemplo n.º 24
0
bool xRedisClient::hdel(const RedisDBIdx& dbi,    const string& key, const KEYS& vfiled, int64_t& count) {
    VDATA vCmdData;
    vCmdData.push_back("HDEL");
    vCmdData.push_back(key);
    addparam(vCmdData, vfiled);
    SETDEFAULTIOTYPE(MASTER);
    return commandargv_integer(dbi, vCmdData, count);
}
Exemplo n.º 25
0
bool xRedisClient::set(const RedisDBIdx& dbi, const string& key, const char *value, int len, int second) {
    SETDEFAULTIOTYPE(MASTER);
    if (0==second) {
        return command_bool(dbi, "set %s %b", key.c_str(), value, len);
    } else {
        return command_bool(dbi, "set %s %b EX %d", key.c_str(), value, len, second);
    }
}
Exemplo n.º 26
0
bool xRedisClient::linsert(const RedisDBIdx& dbi,    const string& key, const LMODEL mod, const string& pivot, const string& value, int64_t& retval) {
	static const char *lmodel[2] = {"BEFORE", "AFTER"};
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	return command_integer(dbi, retval, "LINSERT %s %s %s %s", key.c_str(), lmodel[mod], pivot.c_str(), value.c_str());
}
Exemplo n.º 27
0
bool xRedisClient::hmset(const RedisDBIdx& dbi,    const string& key, const VDATA& vData){
    VDATA vCmdData;
    vCmdData.push_back("HMSET");
    vCmdData.push_back(key);
    addparam(vCmdData, vData);
    SETDEFAULTIOTYPE(MASTER);
    return commandargv_status(dbi, vCmdData);
}
Exemplo n.º 28
0
bool xRedisClient::hmget(const RedisDBIdx& dbi,    const string& key, const KEYS& field, ArrayReply& array){
    VDATA vCmdData;
    vCmdData.push_back("HMGET");
    vCmdData.push_back(key);
    addparam(vCmdData, field);
    SETDEFAULTIOTYPE(SLAVE);
    return commandargv_array(dbi, vCmdData, array);
}
Exemplo n.º 29
0
bool xRedisClient::set(const RedisDBIdx& dbi,    const string& key,  const string& value) {
    VDATA vCmdData;
    vCmdData.push_back("SET");
    vCmdData.push_back(key);
    vCmdData.push_back(value);
    SETDEFAULTIOTYPE(MASTER);
    return commandargv_status(dbi, vCmdData);
}
bool xRedisClient::echo(const RedisDBIdx& dbi, const string& str, std::string &value)
{
	if (0==str.length()) {
        return false;
    }
    SETDEFAULTIOTYPE(MASTER);
    return command_string(dbi, value, "echo %s", str.c_str());
}