acl  3.5.3.0
acl::redis_set类 参考

#include <redis_set.hpp>

+ 类 acl::redis_set 继承关系图:
+ acl::redis_set 的协作图:

Public 成员函数

 redis_set (void)
 
 redis_set (redis_client *conn)
 
 redis_set (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED redis_set (redis_client_cluster *cluster, size_t max_conns)
 
 redis_set (redis_client_pipeline *pipeline)
 
virtual ~redis_set (void)
 
int sadd (const char *key, const char *first_member,...)
 
int sadd (const char *key, const std::vector< const char * > &memsbers)
 
int sadd (const char *key, const std::vector< string > &members)
 
int sadd (const char *key, const char *argv[], size_t argc)
 
int sadd (const char *key, const char *argv[], const size_t lens[], size_t argc)
 
bool spop (const char *key, string &buf)
 
int scard (const char *key)
 
int smembers (const char *key, std::vector< string > *members)
 
int smove (const char *src, const char *dst, const char *member)
 
int smove (const char *src, const char *dst, const string &member)
 
int smove (const char *src, const char *dst, const char *member, size_t len)
 
int sdiff (std::vector< string > *members, const char *first_key,...)
 
int sdiff (const std::vector< const char * > &keys, std::vector< string > *members)
 
int sdiff (const std::vector< string > &keys, std::vector< string > *members)
 
int sinter (std::vector< string > *members, const char *first_key,...)
 
int sinter (const std::vector< const char * > &keys, std::vector< string > *members)
 
int sinter (const std::vector< string > &keys, std::vector< string > *members)
 
int sunion (std::vector< string > *members, const char *first_key,...)
 
int sunion (const std::vector< const char * > &keys, std::vector< string > *members)
 
int sunion (const std::vector< string > &keys, std::vector< string > *members)
 
int sdiffstore (const char *dst, const char *first_key,...)
 
int sdiffstore (const char *dst, const std::vector< const char * > &keys)
 
int sdiffstore (const char *dst, const std::vector< string > &keys)
 
int sinterstore (const char *dst, const char *first_key,...)
 
int sinterstore (const char *dst, const std::vector< const char * > &keys)
 
int sinterstore (const char *dst, const std::vector< string > &keys)
 
int sunionstore (const char *dst, const char *first_key,...)
 
int sunionstore (const char *dst, const std::vector< const char * > &keys)
 
int sunionstore (const char *dst, const std::vector< string > &keys)
 
bool sismember (const char *key, const char *member)
 
bool sismember (const char *key, const char *member, size_t len)
 
int srandmember (const char *key, string &out)
 
int srandmember (const char *key, size_t n, std::vector< string > &out)
 
int srem (const char *key, const char *first_member,...)
 
int srem (const char *key, const std::vector< string > &members)
 
int srem (const char *key, const std::vector< const char * > &members)
 
int srem (const char *key, const char *members[], size_t lens[], size_t argc)
 
int sscan (const char *key, int cursor, std::vector< string > &out, const char *pattern=NULL, const size_t *count=NULL)
 
- Public 成员函数 继承自 acl::redis_command
 redis_command (void)
 
 redis_command (redis_client *conn)
 
 redis_command (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED redis_command (redis_client_cluster *cluster, size_t max_conns)
 
 redis_command (redis_client_pipeline *pipeline)
 
virtual ~redis_command (void)
 
void set_check_addr (bool on)
 
void clear (bool save_slot=false)
 
void reset (bool save_slot=false)
 
void set_client (redis_client *conn)
 
redis_clientget_client (void) const
 
const char * get_client_addr (void) const
 
void set_cluster (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED void set_cluster (redis_client_cluster *cluster, size_t max_conns)
 
redis_client_clusterget_cluster (void) const
 
void set_pipeline (redis_client_pipeline *pipeline, bool use_mbox=true)
 
redis_client_pipelineget_pipeline (void) const
 
dbuf_poolget_dbuf (void) const
 
redis_result_t result_type (void) const
 
const char * result_status (void) const
 
const char * result_error (void) const
 
size_t result_size (void) const
 
int result_number (bool *success=NULL) const
 
long long int result_number64 (bool *success=NULL) const
 
const char * get_result (size_t i, size_t *len=NULL) const
 
bool eof (void) const
 
const redis_resultget_result (void) const
 
const redis_resultresult_child (size_t i) const
 
const char * result_value (size_t i, size_t *len=NULL) const
 
void set_slice_request (bool on)
 
void set_slice_respond (bool on)
 
const redis_resultrequest (size_t argc, const char *argv[], size_t lens[], size_t nchild=0)
 
const redis_resultrequest (const std::vector< string > &args, size_t nchild=0)
 
const stringrequest_buf (void) const
 
void build_request (size_t argc, const char *argv[], size_t lens[])
 
void hash_slot (const char *key)
 
void hash_slot (const char *key, size_t len)
 
int get_slot (void) const
 
bool is_check_addr (void) const
 
const char * get_addr (const char *info)
 
void set_client_addr (const char *addr)
 
void set_client_addr (redis_client &conn)
 
redis_request * get_request_obj (void) const
 
stringget_request_buf (void) const
 
bool is_slice_req (void) const
 
redis_pipeline_messageget_pipeline_message (void)
 

额外继承的成员函数

- 静态 Public 成员函数 继承自 acl::redis_command
static void build_request (size_t argc, const char *argv[], size_t lens[], string &out)
 
- Protected 成员函数 继承自 acl::redis_command
const redis_resultrun (size_t nchild=0, int *timeout=NULL)
 
void clear_request (void)
 
const redis_result ** scan_keys (const char *cmd, const char *key, int &cursor, size_t &size, const char *pattern, const size_t *count)
 
const redis_result ** scan_keys (const char *cmd, const char *key, size_t klen, int &cursor, size_t &size, const char *pattern, const size_t *count)
 
void build (const char *cmd, const char *key, const std::map< string, string > &attrs)
 
void build (const char *cmd, const char *key, size_t klen, const std::map< string, string > &attrs)
 
void build (const char *cmd, const char *key, const std::map< string, const char * > &attrs)
 
void build (const char *cmd, const char *key, const std::vector< string > &names, const std::vector< string > &values)
 
void build (const char *cmd, const char *key, size_t klen, const std::vector< string > &names, const std::vector< string > &values)
 
void build (const char *cmd, const char *key, const std::vector< const char * > &names, const std::vector< const char * > &values)
 
void build (const char *cmd, const char *key, const char *names[], const char *values[], size_t argc)
 
void build (const char *cmd, const char *key, const int names[], const char *values[], size_t argc)
 
void build (const char *cmd, const char *key, const char *names[], const size_t names_len[], const char *values[], const size_t values_len[], size_t argc)
 
void build (const char *cmd, const char *key, size_t klen, const char *names[], const size_t names_len[], const char *values[], const size_t values_len[], size_t argc)
 
void build (const char *cmd, const char *key, const std::vector< string > &names)
 
void build (const char *cmd, const char *key, size_t klen, const std::vector< string > &names)
 
void build (const char *cmd, const char *key, const std::vector< const char * > &names)
 
void build (const char *cmd, const char *key, const std::vector< int > &names)
 
void build (const char *cmd, const char *key, const char *names[], size_t argc)
 
void build (const char *cmd, const char *key, const char *names[], const size_t lens[], size_t argc)
 
void build (const char *cmd, const char *key, size_t klen, const char *names[], const size_t lens[], size_t argc)
 
void build (const char *cmd, const char *key, const int names[], size_t argc)
 
int get_number (bool *success=NULL)
 
long long int get_number64 (bool *success=NULL)
 
int get_number (std::vector< int > &out)
 
int get_number64 (std::vector< long long int > &out)
 
bool check_status (const char *success="OK")
 
int get_status (std::vector< bool > &out)
 
const char * get_status (void)
 
int get_string (string &buf)
 
int get_string (string *buf)
 
int get_string (char *buf, size_t size)
 
int get_strings (std::vector< string > &result)
 
int get_strings (std::vector< string > *result)
 
int get_strings (std::list< string > &result)
 
int get_strings (std::list< string > *result)
 
int get_strings (std::map< string, string > &result)
 
int get_strings (std::vector< string > &names, std::vector< string > &values)
 
int get_strings (std::vector< const char * > &names, std::vector< const char * > &values)
 
void argv_space (size_t n)
 
void build_request1 (size_t argc, const char *argv[], size_t lens[])
 
void build_request2 (size_t argc, const char *argv[], size_t lens[])
 
void logger_result (const redis_result *result)
 
- Protected 成员函数 继承自 acl::acl::noncopyable
 noncopyable ()
 
 ~noncopyable ()
 
- Protected 属性 继承自 acl::redis_command
dbuf_pooldbuf_
 
bool check_addr_
 
char addr_ [32]
 
redis_clientconn_
 
redis_client_clustercluster_
 
redis_client_pipelinepipeline_
 
bool pipe_use_mbox_
 
int slot_
 
int redirect_max_
 
int redirect_sleep_
 
bool slice_req_
 
stringrequest_buf_
 
redis_request * request_obj_
 
size_t argv_size_
 
const char ** argv_
 
size_t * argv_lens_
 
size_t argc_
 
bool slice_res_
 
redis_pipeline_messagepipe_msg_
 
const redis_resultresult_
 

详细描述

在文件 redis_set.hpp12 行定义.

构造及析构函数说明

◆ redis_set() [1/5]

acl::redis_set::redis_set ( void  )

◆ redis_set() [2/5]

acl::redis_set::redis_set ( redis_client conn)

◆ redis_set() [3/5]

acl::redis_set::redis_set ( redis_client_cluster cluster)

◆ redis_set() [4/5]

ACL_CPP_DEPRECATED acl::redis_set::redis_set ( redis_client_cluster cluster,
size_t  max_conns 
)

◆ redis_set() [5/5]

acl::redis_set::redis_set ( redis_client_pipeline pipeline)

◆ ~redis_set()

virtual acl::redis_set::~redis_set ( void  )
virtual

成员函数说明

◆ sadd() [1/5]

int acl::redis_set::sadd ( const char *  key,
const char *  first_member,
  ... 
)

将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素 将被忽略; 1) 假如 key 不存在,则创建一个只包含 member 元素作成员的集合 2) 当 key 不是集合类型时,返回一个错误 add one or more members to a set stored at a key 1) if the key doesn't exist, a new set by the key will be created, and add the members to the set 2) if the key exists and not a set's key, then error happened

参数
key{const char*} 集合对象的键 the key of a set
first_member{const char*} 第一个非 NULL 的成员 the first member of a variable args which isn't NULL, the last arg of the args must be NULL indicating the end of args
返回
{int} 被添加到集合中的新元素的数量,不包括被忽略的元素 the number of elements that were added to the set, not including all the elements already present into the set. -1 if error happened or it isn't a set stored by the key.

◆ sadd() [2/5]

int acl::redis_set::sadd ( const char *  key,
const std::vector< const char * > &  memsbers 
)

◆ sadd() [3/5]

int acl::redis_set::sadd ( const char *  key,
const std::vector< string > &  members 
)

◆ sadd() [4/5]

int acl::redis_set::sadd ( const char *  key,
const char *  argv[],
size_t  argc 
)

◆ sadd() [5/5]

int acl::redis_set::sadd ( const char *  key,
const char *  argv[],
const size_t  lens[],
size_t  argc 
)

◆ scard()

int acl::redis_set::scard ( const char *  key)

获得集合对象中成员的数量 get the number of members in a set stored at the key

参数
key{const char*} 集合对象的键 the key of the set
返回
{int} 返回该集合对象中成员数量,含义如下: return int value as below: -1:出错或非集合对象 error or it's not a set by the key 0:成员数量为空或该 key 不存在 the set is empty or the key doesn't exist >0:成员数量非空 the number of members in the set

◆ sdiff() [1/3]

int acl::redis_set::sdiff ( std::vector< string > *  members,
const char *  first_key,
  ... 
)

返回一个集合的全部成员,该集合是所有给定集合之间的差集 return the members of the set resulting from the difference between the first set and all the successive sets.

参数
members{std::vector<string>*} 非空时存储结果集 if not NULL, it will store the members.
first_key{const char*} 第一个非空的集合对象 key the key of the first set in a variable sets list, the last one must be NULL indicating the end of the sets list.
返回
{int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象 the number of elements got, -1 if error happened or it't not a set by the key. 操作成功后可以通过以下任一方式获得数据 if successul, one of below ways can be used to get the result: 1、在调用方法中传入非空的存储结果对象的地址 the most easily way is to set a non-NULL result parameter for this function 2、基类方法 get_value 获得指定下标的元素数据 get the specified subscript's element by redis_command::get_value 3、基类方法 get_child 获得指定下标的元素对象(redis_result),然后再通过 redis_result::argv_to_string 方法获得元素数据 get redis_result object with the given subscript, and get the element by redis_result::argv_to_string 4、基类方法 get_result 方法取得总结果集对象 redis_result,然后再通过 redis_result::get_child 获得一个元素对象,然后再通过方式 2 中指定 的方法获得该元素的数据 get redis_result object by redis_command::get_result, and get the first element by redis_result::get_child, then get the element by the way same as the way 2 above. 5、基类方法 get_children 获得结果元素数组对象,再通过 redis_result 中 的方法 argv_to_string 从每一个元素对象中获得元素数据 get child array by redis_command::get_children, and get the element from one of redis_result array by argv_to_string

◆ sdiff() [2/3]

int acl::redis_set::sdiff ( const std::vector< const char * > &  keys,
std::vector< string > *  members 
)

◆ sdiff() [3/3]

int acl::redis_set::sdiff ( const std::vector< string > &  keys,
std::vector< string > *  members 
)

◆ sdiffstore() [1/3]

int acl::redis_set::sdiffstore ( const char *  dst,
const char *  first_key,
  ... 
)

这个命令的作用和 SDIFF 类似,但它将结果保存到 dst 集合,而不是简单地返回结果集 This command is equal to SDIFF, but instead of returning the resulting set, it is stored in destination.

参数
dst{const char*} 目标集合对象键值 the key of the destination set
first_key{const char*} 第一个非空的集合对象键值 the key of the first set in a variable set list, which isn't NULL, and the last arg must be NULL indicating the end of the set list.
返回
{int} 结果集中的成员数量 return the number of members, -1 if error happened or it's not a set by the key.

◆ sdiffstore() [2/3]

int acl::redis_set::sdiffstore ( const char *  dst,
const std::vector< const char * > &  keys 
)

◆ sdiffstore() [3/3]

int acl::redis_set::sdiffstore ( const char *  dst,
const std::vector< string > &  keys 
)

◆ sinter() [1/3]

int acl::redis_set::sinter ( std::vector< string > *  members,
const char *  first_key,
  ... 
)

返回一个集合的全部成员,该集合是所有给定集合的交集 return the members of a set resulting from the intersection of all the give sets.

参数
members{std::vector<string>*} 非空时存储结果集 if not NULL, it will store the result
first_key{const char*} 第一个集合对象 key(非NULL) the key of the first set in a variable set list, which isn't NULL, the last one must be NULL in the set list.
返回
{int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象 return the number of the members, -1 if error happened or it't not a set by the key.

◆ sinter() [2/3]

int acl::redis_set::sinter ( const std::vector< const char * > &  keys,
std::vector< string > *  members 
)

◆ sinter() [3/3]

int acl::redis_set::sinter ( const std::vector< string > &  keys,
std::vector< string > *  members 
)

◆ sinterstore() [1/3]

int acl::redis_set::sinterstore ( const char *  dst,
const char *  first_key,
  ... 
)

这个命令类似于 SINTER 命令,但它将结果保存到 dst 集合,而不是简单地返回结果集 This command is equal to SINTER, but instead of returning the resulting set, it is stored in destination.

参数
dst{const char*} 目标集合对象键值 the key of the destination set
first_key{const char*} 第一个非空的集合对象键值 the key of the first set in a variable set list, which isn't NULL, and the last arg must be NULL indicating the end of the set list.
返回
{int} 结果集中的成员数量 return the number of members, -1 if error happened or it's not a set by the key.

◆ sinterstore() [2/3]

int acl::redis_set::sinterstore ( const char *  dst,
const std::vector< const char * > &  keys 
)

◆ sinterstore() [3/3]

int acl::redis_set::sinterstore ( const char *  dst,
const std::vector< string > &  keys 
)

◆ sismember() [1/2]

bool acl::redis_set::sismember ( const char *  key,
const char *  member 
)

判断 member 元素是否集合 key 的成员 determine if a given value is a member of a set

参数
key{const char*} 集合对象的键值 the key of a set
member{const char*} 给定值 the given value
返回
{bool} 返回 true 表示是,否则可能是因为不是或出错或该 key 对象 非集合对象 true if the given is a member of the set, false if it's not a member of the set, or error, or it's not a set by the key.

◆ sismember() [2/2]

bool acl::redis_set::sismember ( const char *  key,
const char *  member,
size_t  len 
)

◆ smembers()

int acl::redis_set::smembers ( const char *  key,
std::vector< string > *  members 
)

返回集合 key 中的所有成员 get all the members in a set stored at a key

参数
key{const char*} 集合对象的键值 the key of the set
members{std::vector<string>*} 非空时存储结果集 if not NULL, it will store the members.
返回
{int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象 the number of elements got, -1 if error happened or it't not a set by the key.

操作成功后可以通过以下任一方式获得数据 if successul, one of below ways can be used to get the result: 1、在调用方法中传入非空的存储结果对象的地址 the most easily way is to set a non-NULL result parameter for this function 2、基类方法 get_value 获得指定下标的元素数据 call redis_command::result_value with the specified subscript 3、基类方法 get_child 获得指定下标的元素对象(redis_result),然后再通过 redis_result::argv_to_string 方法获得元素数据 get redis_result object with the given subscript, and get the element by redis_result::argv_to_string 4、基类方法 get_result 方法取得总结果集对象 redis_result,然后再通过 redis_result::get_child 获得一个元素对象,然后再通过方式 2 中指定 的方法获得该元素的数据 get redis_result object by redis_command::get_result, and get the first element by redis_result::get_child, then get the element by the way same as the way 2 above 5、基类方法 get_children 获得结果元素数组对象,再通过 redis_result 中 的方法 argv_to_string 从每一个元素对象中获得元素数据 get child array by redis_command::get_children, and get the element from one of redis_result array by argv_to_string

◆ smove() [1/3]

int acl::redis_set::smove ( const char *  src,
const char *  dst,
const char *  member 
)

将 member 元素从 src 集合移动到 dst 集合 move a member from one set to another

参数
src{const char*} 源集合对象的键值 the source key of a set
dst{const char*} 目标集合对象的键值 the destination key of a set
member{const char*} 源集合对象的成员 the member in the source set
返回
{int} 返回值含义如下: return int value as below: -1:出错或源/目标对象有一个非集合对象 error happened, or one of source and destination isn't a set 0:源对象不存在或成员在源对象中不存在 the source set or the member doesn't exist 1:成功从源对象中将一个成员移动至目标对象中 move successfully the member from source set to the destination set

◆ smove() [2/3]

int acl::redis_set::smove ( const char *  src,
const char *  dst,
const string member 
)

◆ smove() [3/3]

int acl::redis_set::smove ( const char *  src,
const char *  dst,
const char *  member,
size_t  len 
)

◆ spop()

bool acl::redis_set::spop ( const char *  key,
string buf 
)

从集合对象中随机移除并返回某个成员 remove and get one member from the set

参数
key{const char*} 集合对象的键 the key of the set
buf{string&} 存储被移除的成员 store the member removed from the set
返回
{bool} 当 key 不存在或 key 是空集时返回 false true if one member has been removed and got, false if the key doesn't exist or it isn't a set stored at the key.

◆ srandmember() [1/2]

int acl::redis_set::srandmember ( const char *  key,
string out 
)

如果命令执行时,只提供了 key 参数,那么返回集合中的一个随机元素,如果还同时指定 了元素个数,则会返回一个不超过该个数限制的结果集 get one or multiple memebers from a set

参数
key{const char*} 集合对象的键值 the key of a set
out存储结果或结果集 store the result
返回
{int} 结果的个数,为 -1 表示出错,0 表示没有成员 the number of members, 0 if the set by the key is empty, -1 if error happened.

◆ srandmember() [2/2]

int acl::redis_set::srandmember ( const char *  key,
size_t  n,
std::vector< string > &  out 
)

◆ srem() [1/4]

int acl::redis_set::srem ( const char *  key,
const char *  first_member,
  ... 
)

移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略 Remove the specified members from the set stored at key. if the member doesn't exist, it will be ignored.

参数
key{const char*} 集合对象的键值 the key of the set
first_member{const char*} 需要被移除的成员列表的第一个非 NULL成员, 在变参的输入中需要将最后一个变参写 NULL the first non-NULL member to be removed in a variable member list, and the last one must be NULL indicating the end of the list. @retur {int} 被移除的成员元素的个数,当出错或非集合对象时返回 -1;当 key 不 存在或成员不存在时返回 0 the number of members be removed, 0 if the set is empty or the key doesn't exist, -1 if error happened or it's not a set by key

◆ srem() [2/4]

int acl::redis_set::srem ( const char *  key,
const std::vector< string > &  members 
)

◆ srem() [3/4]

int acl::redis_set::srem ( const char *  key,
const std::vector< const char * > &  members 
)

◆ srem() [4/4]

int acl::redis_set::srem ( const char *  key,
const char *  members[],
size_t  lens[],
size_t  argc 
)

◆ sscan()

int acl::redis_set::sscan ( const char *  key,
int  cursor,
std::vector< string > &  out,
const char *  pattern = NULL,
const size_t *  count = NULL 
)

命令用于迭代当前数据库中的数据库键 scan the members in a set stored at key

参数
key{const char*} 哈希键值 the key of a set
cursor{int} 游标值,开始遍历时该值写 0 the cursor value, which is 0 at begin
out{std::vector<string>&} 存储结果集,内部以追加方式将本次遍历 结果集合添加进该数组中,为防止因总结果集过大导致该数组溢出,用户可在调用本 函数前后清理该数组对象 store result in appending mode.
pattern{const char*} 匹配模式,glob 风格,非空时有效 match pattern, effective only on no-NULL
count{const size_t*} 限定的结果集数量,非空指针时有效 the max count of one scan process, effective only on no-NULL
返回
{int} 下一个游标位置,含义如下: return the next cursor position, as below: 0:遍历结束 scan finish -1: 出错 some error happened >0: 游标的下一个位置,即使这样,具体有多少结果还需要检查 out,因为有可能为空 the next cursor postion to scan

◆ sunion() [1/3]

int acl::redis_set::sunion ( std::vector< string > *  members,
const char *  first_key,
  ... 
)

返回一个集合的全部成员,该集合是所有给定集合的并集 return the members of a set resulting from the union of all the given sets.

参数
members{std::vector<string>*} 非空时存储结果集 if not NULL, it will store the result
first_key{const char*} 第一个集合对象 key(非NULL) the key of the first set in a variable set list, which isn't NULL, and the last arg must be NULL indicating the end of the set list.
返回
{int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象 return the number of members, -1 if error happened or it's not a set by the key.

◆ sunion() [2/3]

int acl::redis_set::sunion ( const std::vector< const char * > &  keys,
std::vector< string > *  members 
)

◆ sunion() [3/3]

int acl::redis_set::sunion ( const std::vector< string > &  keys,
std::vector< string > *  members 
)

◆ sunionstore() [1/3]

int acl::redis_set::sunionstore ( const char *  dst,
const char *  first_key,
  ... 
)

这个命令类似于 SUNION 命令,但它将结果保存到 dst 集合,而不是简单地返回结果集 This command is equal to SUNION, but instead of returning the resulting set, it is stored in destination.

参数
dst{const char*} 目标集合对象键值 the key of the destination set
first_key{const char*} 第一个非空的集合对象键值 the key of the first set in a variable set list, which isn't NULL, and the last arg must be NULL indicating the end of the set list.
返回
{int} 结果集中的成员数量 return the number of members, -1 if error happened or it's not a set by the key.

◆ sunionstore() [2/3]

int acl::redis_set::sunionstore ( const char *  dst,
const std::vector< const char * > &  keys 
)

◆ sunionstore() [3/3]

int acl::redis_set::sunionstore ( const char *  dst,
const std::vector< string > &  keys 
)

该类的文档由以下文件生成: