Permalink
Browse files

Added SET support

  • Loading branch information...
1 parent 557e4b0 commit 28d2aad2e6f1cbd5030422eebb3676403a3cf665 Joegen Baclor committed Aug 14, 2012
Showing with 54 additions and 0 deletions.
  1. +54 −0 sipXsqa/include/sqa/RedisClient.h
@@ -458,6 +458,60 @@ class RedisClient : boost::noncopyable
return !keys.empty();
}
+ bool smembers(const std::string& key, std::vector<std::string>& members)
+ {
+ std::vector<std::string> args;
+ args.push_back("SMEMBERS");
+ args.push_back(key);
+ members = getReplyStringArray(args);
+ return !members.empty();
+ }
+
+ long long sadd(const std::string& key, const std::vector<std::string>& members)
+ {
+ std::vector<std::string> args;
+ args.push_back("SADD");
+ args.push_back(key);
+
+ for (std::vector<std::string>::const_iterator iter = members.begin(); iter != members.end(); iter++)
+ args.push_back(*iter);
+ long long result = 0;
+ getReplyInt(args, result);
+ return result;
+ }
+
+ long long scard(const std::string& key)
+ {
+ std::vector<std::string> args;
+ args.push_back("SCARD");
+ args.push_back(key);
+ long long result = 0;
+ getReplyInt(args, result);
+ return result;
+ }
+
+ long long srem(const std::string& key, const std::vector<std::string>& members)
+ {
+ std::vector<std::string> args;
+ args.push_back("SREM");
+ args.push_back(key);
+
+ for (std::vector<std::string>::const_iterator iter = members.begin(); iter != members.end(); iter++)
+ args.push_back(*iter);
+ long long result = 0;
+ getReplyInt(args, result);
+ return result;
+ }
+
+ std::string spop(const std::string& key)
+ {
+ std::vector<std::string> args;
+ args.push_back("SPOP");
+ args.push_back(key);
+ return getReplyString(args);
+ }
+
+
bool del(const std::string& key)
{
std::vector<std::string> args;

0 comments on commit 28d2aad

Please sign in to comment.