本文整理汇总了C++中credisclient::VecString::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ VecString::begin方法的具体用法?C++ VecString::begin怎么用?C++ VecString::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类credisclient::VecString
的用法示例。
在下文中一共展示了VecString::begin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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" );
}
}
示例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: 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 ) );
}
示例7: 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);
}
示例8: 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;
}
示例9: 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 );
}
示例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
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;
}
示例13: TestSet
///////////////////////////////////////////// test set //////////////////////////////////////////
void TestSet( void )
{
try
{
CRedisClient redis;
redis.connect( "127.0.0.1", 6379 );
//--------------------------test sadd-------------------------------
CRedisClient::VecString members;
members.push_back( "yuhaiyang" );
members.push_back( "zhouli" );
members.push_back( "严兴俊" );
uint64_t saddNum = redis.sadd( "testSet", members );
std::cout << "saddNum: " << saddNum << std::endl;
//-------------------------test scard--------------------------------
uint64_t scardNum = redis.scard( "testSet" );
std::cout << "scardNum:" << scardNum << std::endl;
//-------------------------test sdiff----------------------------------
std::cout << "=====================================sdiffData==========================" << std::endl;
CRedisClient::VecString keys;
keys.push_back("testSet");
keys.push_back("testSet2");
CRedisClient::VecString sdiffValues;
uint64_t sdiffNum = redis.sdiff( keys, sdiffValues );
std::cout << "sdiffNum: " << sdiffNum << std::endl;
//-------------------------test sdiffstore----------------------------
CRedisClient::VecString sdiffstorekeys;
sdiffstorekeys.push_back("testSet");
sdiffstorekeys.push_back("testSet2");
uint64_t sdiffstoreNum = redis.sdiffstore( "diffSetKey",sdiffstorekeys );
std::cout << "===========================sdiffNum=================================" << std::endl;
std::cout << "sdiffstoreNum: " << sdiffstoreNum << std::endl;
//---------------------------test sinter--------------------------------
CRedisClient::VecString sinterValues;
CRedisClient::VecString sinterKeys;
sinterKeys.push_back( "testSet" );
sinterKeys.push_back( "testSet2" );
uint64_t sinterNum = redis.sinter( sinterKeys, sinterValues );
std::cout << "===========================sinterNum================================" << std::endl;
std::cout << "sinterNum: " << sinterNum << std::endl;
CRedisClient::VecString::const_iterator sinterIt = sinterValues.begin();
CRedisClient::VecString::const_iterator sinterEnd = sinterValues.end();
for ( ; sinterIt != sinterEnd; ++sinterIt )
{
std::cout << "sinterIt: " << *sinterIt << std::endl;
}
//-----------------------------test sinterstore---------------------------
CRedisClient::VecString sinterstoreKeys;
sinterstoreKeys.push_back( "testSet" );
sinterstoreKeys.push_back( "testSet2" );
uint64_t sinterstoreNum = redis.sinterstore( "interSetKey", sinterstoreKeys );
std::cout << "sinterstoreNum: " << sinterstoreNum << std::endl;
//----------------------------test sismember----------------------------
bool ret = redis.sismember( "testSet", "yuhaiyang2" );
if ( ret )
{
std::cout << "存在" << std::endl;
}else
{
std::cout << "不存在" << std::endl;
}
CRedisClient::VecString membersMembers;
uint64_t smembersNum = redis.smembers( "testSet", membersMembers );
std::cout << "smembersNum" << smembersNum << std::endl;
PrintVector( "members", membersMembers );
//-----------------------------test smove-------------------------------------
bool smoveRet = redis.smove( "testSet2", "testSet","duzong");
if ( smoveRet )
{
std::cout << "smove ok" << std::endl;
}else
{
std::cout << "smove failed" << std::endl;
}
//-----------------------------test spop--------------------------------------
string spopMember;
bool spopRet = redis.spop( "testSet3", spopMember );
if ( spopRet )
{
std::cout << "spop ok" << std::endl;
std::cout << "spop data:" << spopMember << std::endl;
}else
{
std::cout << "spop faliled" << std::endl;
}
//-----------------------------test srandmember-----------------------------
string srandmember;
bool srandRet = redis.srandmember( "testSet3", srandmember );
if ( srandRet )
{
std::cout << "srandmember ok" <<std::endl;
std::cout << "srandmember data:" << srandmember << std::endl;
}else
{
//.........这里部分代码省略.........
示例14: TestHash
void TestHash( void )
{
try
{
CRedisClient redis;
redis.connect( "127.0.0.1", 6379 );
//-------------------------test hset hget---------------------------------
string value;
int32_t hashRet = redis.hset( "testHash", "name5", "{ \n\"value\" : \"yuhaiyang\"\r\n}\n" );
std::cout << "hashRet: " << hashRet << std::endl;
bool ret = redis.hget( "testHash", "name5" ,value );
std::cout << "ret: " << ret << std::endl;
std::cout << "value:" << value << std::endl;
//------------------------test hdel------------------------------------------
CRedisClient::VecString fields;
fields.push_back( "name4" );
fields.push_back( "name5" );
uint64_t delNum = redis.hdel( "member", fields );
std::cout << "delNum: " << delNum << std::endl;
//------------------------test hexists---------------------------------------
string field = "name4";
bool isExists = redis.hexists( "testHash", field );
if ( isExists )
std::cout << "testHash key exists field:" << field << std::endl;
else
std::cout << "testHash key not exists field:" << field << std::endl;
//-----------------------test hgetall-------------------------------------------
CRedisClient::MapString allValue;
uint64_t allNum = redis.hgetall( "testHash", allValue );
std::cout << "allNum: " << allNum <<std::endl;
CRedisClient::MapString::const_iterator it = allValue.begin();
for ( ; it != allValue.end(); it++ )
{
std::cout << it->first << ":" << it->second << std::endl;
}
//------------------------test incrby-------------------------------------------
uint64_t incrybyNum = redis.hincrby( "testHash", "num2", 20 );
std::cout << "incrybyNum: " << incrybyNum << std::endl;
//------------------------test incrbyfloat-------------------------------------
float floatNum = redis.hincrbyfloat( "testHash", "float", 10.1e2 );
std::cout << "floatNum: " << floatNum << std::endl;
//------------------------test hkeys-------------------------------------------
CRedisClient::VecString hkeysValue;
uint64_t hkeysNum = redis.hkeys( "testHash", hkeysValue );
std::cout << "hkeysNum: " << hkeysNum << std::endl;
CRedisClient::VecString::const_iterator hkeysit = hkeysValue.begin();
for ( ; hkeysit != hkeysValue.end(); hkeysit++ )
{
std::cout << *hkeysit << std::endl;
}
//------------------------test hlen-----------------------------------------------
// uint64_t fieldNum = redis.hlen( "testHash" );
// std::cout << "fieldNum: " << fieldNum << std::endl;
// //------------------------test hmget---------------------------------------------
// CResult result;
// CRedisClient::VecString hmgeFields;
// hmgeFields.push_back("name4");
// hmgeFields.push_back("yuhaiyang");
// hmgeFields.push_back("num");
// redis.hmget( "testHash", hmgeFields,result );
// std::cout << "hmget:" << std::endl;
// std::cout << result << std::endl;
}catch( RdException& e )
{
std::cout << "Redis exception:" << e.what() << std::endl;
}catch( Poco::Exception& e )
{
std::cout << "Poco_exception:" << e.what() << std::endl;
}
}