本文整理汇总了C++中credisclient::VecString类的典型用法代码示例。如果您正苦于以下问题:C++ VecString类的具体用法?C++ VecString怎么用?C++ VecString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VecString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hmget
void CRedisClient::hmget(const string &key, const CRedisClient::VecString &fields, CResult &result)
{
_socket.clearBuffer();
Command cmd( "HMGET" );
cmd << key;
VecString::const_iterator it = fields.begin();
VecString::const_iterator end = fields.end();
for ( ; it != end; ++it )
{
cmd << *it;
}
_sendCommand( cmd );
_getReply( result );
ReplyType type = result.getType();
if ( REDIS_REPLY_ERROR == type )
{
throw ReplyErr( result.getErrorString() );
}else if ( REDIS_REPLY_ARRAY != type )
{
throw ProtocolErr( "HMGET: data recved is not arry" );
}
}
示例2: TestPfmerge
void TestPfmerge( void )
{
try
{
CRedisClient redis;
redis.connect("127.0.0.1", 6379);
CRedisClient::VecString element;
element.push_back("a");
element.push_back("b");
element.push_back("c");
string key1("key1");
redis.pfadd(key1, element);
CRedisClient::VecString element2;
element2.push_back("a");
element2.push_back("d");
string key2("key2");
redis.pfadd(key2, element2);
CRedisClient::VecString keys;
keys.push_back(key1);
keys.push_back(key2);
bool flag = redis.pfmerge("test", keys);
cout << flag << endl;
} catch( RdException& e )
{
std::cout << "Redis exception:" << e.what() << std::endl;
} catch( Poco::Exception& e )
{
std::cout << "Poco_exception:" << e.what() << std::endl;
}
}
示例3: TestLrange
void TestLrange( void )
{
try
{
CRedisClient redis;
redis.connect("127.0.0.1", 6379);
string mykey = "key";
CRedisClient::VecString value;
int64_t start = 0;
int64_t stop = 33;
uint64_t count = redis.lrange(mykey, start, stop, value);
std::cout << count << std::endl;
CRedisClient::VecString::const_iterator it = value.begin();
CRedisClient::VecString::const_iterator end = value.end();
while ( it != end )
{
cout << *it << endl;
++it;
}
} catch( RdException& e )
{
std::cout << "Redis exception:" << e.what() << std::endl;
} catch( Poco::Exception& e )
{
std::cout << "Poco_exception:" << e.what() << std::endl;
}
}
示例4: PrintVector
void PrintVector( const string& key,CRedisClient::VecString& values )
{
CRedisClient::VecString::const_iterator it = values.begin();
CRedisClient::VecString::const_iterator end = values.end();
for ( ; it != end; ++it )
{
std::cout << key << ": " << *it << std::endl;
}
}
示例5: sinter
uint64_t CRedisClient::sinter(const CRedisClient::VecString &keys, VecString &values)
{
Command cmd( "SINTER" );
VecString::const_iterator it = keys.begin();
VecString::const_iterator end = keys.end();
for ( ; it != end; ++it )
{
cmd << *it;
}
return ( _getArry( cmd, values ) );
}
示例6: slowlog
void CRedisClient::slowlog(const CRedisClient::VecString &subcommand, CResult &reply)
{
Command cmd( "SLOWLOG" );
_socket.clearBuffer();
VecString::const_iterator it = subcommand.begin();
VecString::const_iterator end=subcommand.end();
for ( ; it !=end; ++it )
{
cmd << *it;
}
_sendCommand(cmd);
_getReply(reply);
}
示例7: sunion
uint64_t CRedisClient::sunion(const CRedisClient::VecString &keys , VecString &members)
{
Command cmd( "SUNION" );
VecString::const_iterator it = keys.begin();
VecString::const_iterator end = keys.end();
for ( ; it != end; ++it )
{
cmd << *it;
}
return ( _getArry( cmd, members ) );
}
示例8: hmget
void CRedisClient::hmget(const string &key, const CRedisClient::VecString &fields, CResult &result)
{
Command cmd( "HMGET" );
cmd << key;
VecString::const_iterator it = fields.begin();
VecString::const_iterator end = fields.end();
for ( ; it != end; ++it )
{
cmd << *it;
}
_getArry( cmd , result );
}
示例9: sunionstroe
uint64_t CRedisClient::sunionstroe(const string &dest, const CRedisClient::VecString &keys)
{
Command cmd( "SUNIONSTORE" );
cmd << dest;
VecString::const_iterator it = keys.begin();
VecString::const_iterator end = keys.end();
for ( ; it != end; ++it )
{
cmd << *it;
}
int64_t num;
_getInt( cmd, num );
return num;
}
示例10: sinterstore
uint64_t CRedisClient::sinterstore( const string& destKey ,const CRedisClient::VecString &keys )
{
Command cmd( "SINTERSTORE" );
cmd << destKey;
VecString::const_iterator it = keys.begin();
VecString::const_iterator end = keys.end();
for ( ; it != end; ++it )
{
cmd << *it;
}
int64_t num = 0;
_getInt( cmd, num );
return num;
}
示例11: sadd
uint64_t CRedisClient::sadd(const string &key, const CRedisClient::VecString &members)
{
Command cmd( "SADD" );
cmd << key;
VecString::const_iterator it = members.begin();
VecString::const_iterator end = members.end();
for ( ; it != end ; ++it )
{
cmd << *it;
}
int64_t num;
_getInt( cmd , num );
return num;
}
示例12: hdel
void CRedisClient::hdel(const string &key, const CRedisClient::VecString &fields, CResult &result )
{
_socket.clearBuffer();;
Command cmd( "HDEL" );
cmd << key;
VecString::const_iterator it = fields.begin();
VecString::const_iterator end = fields.begin();
for ( ; it != end; ++it )
{
cmd << *it;
}
_sendCommand( cmd );
_getReply( result );
}
示例13: hdel
uint64_t CRedisClient::hdel( const string &key, const CRedisClient::VecString &fields )
{
Command cmd( "HDEL" );
cmd << key;
VecString::const_iterator it = fields.begin();
VecString::const_iterator end = fields.end();
for ( ; it != end; ++it )
{
cmd << *it;
}
int64_t num = 0;
_getInt( cmd , num );
return num;
}
示例14: stringToVecString
uint64_t CRedisClient::stringToVecString(string& str, CRedisClient::VecString& vec)
{
uint64_t i=0;
uint64_t len=str.length();
uint64_t posStart=0;
while(i<len)
{
if (str[i]=='\n')
{
vec.push_back(str.substr(posStart,i-posStart));
posStart=i+1;
}
++i;
}
return vec.size();
}
示例15: hvals
uint64_t CRedisClient::hvals(const string &key, CRedisClient::VecString &values)
{
CResult result;
hvals( key, result );
ReplyType type = result.getType();
if ( REDIS_REPLY_ERROR == type )
{
throw ReplyErr( result.getErrorString() );
}else if ( REDIS_REPLY_ARRAY != type )
{
throw ProtocolErr( "HVALS: data recved is not arry");
}
CResult::ListCResult::const_iterator it = result.getArry().begin();
CResult::ListCResult::const_iterator end = result.getArry().end();
for ( ; it != end; ++it )
{
values.push_back( static_cast<string>(*it) );
}
return values.size();
}