acl
3.5.3.0
|
#include <redis_set.hpp>
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_client * | get_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_cluster * | get_cluster (void) const |
void | set_pipeline (redis_client_pipeline *pipeline, bool use_mbox=true) |
redis_client_pipeline * | get_pipeline (void) const |
dbuf_pool * | get_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_result * | get_result (void) const |
const redis_result * | result_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_result * | request (size_t argc, const char *argv[], size_t lens[], size_t nchild=0) |
const redis_result * | request (const std::vector< string > &args, size_t nchild=0) |
const string * | request_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 |
string * | get_request_buf (void) const |
bool | is_slice_req (void) const |
redis_pipeline_message & | get_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_result * | run (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_pool * | dbuf_ |
bool | check_addr_ |
char | addr_ [32] |
redis_client * | conn_ |
redis_client_cluster * | cluster_ |
redis_client_pipeline * | pipeline_ |
bool | pipe_use_mbox_ |
int | slot_ |
int | redirect_max_ |
int | redirect_sleep_ |
bool | slice_req_ |
string * | request_buf_ |
redis_request * | request_obj_ |
size_t | argv_size_ |
const char ** | argv_ |
size_t * | argv_lens_ |
size_t | argc_ |
bool | slice_res_ |
redis_pipeline_message * | pipe_msg_ |
const redis_result * | result_ |
在文件 redis_set.hpp 第 12 行定义.
acl::redis_set::redis_set | ( | void | ) |
acl::redis_set::redis_set | ( | redis_client * | conn | ) |
acl::redis_set::redis_set | ( | redis_client_cluster * | cluster | ) |
ACL_CPP_DEPRECATED acl::redis_set::redis_set | ( | redis_client_cluster * | cluster, |
size_t | max_conns | ||
) |
acl::redis_set::redis_set | ( | redis_client_pipeline * | pipeline | ) |
|
virtual |
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 acl::redis_set::sadd | ( | const char * | key, |
const std::vector< const char * > & | memsbers | ||
) |
int acl::redis_set::sadd | ( | const char * | key, |
const std::vector< string > & | members | ||
) |
int acl::redis_set::sadd | ( | const char * | key, |
const char * | argv[], | ||
size_t | argc | ||
) |
int acl::redis_set::sadd | ( | const char * | key, |
const char * | argv[], | ||
const size_t | lens[], | ||
size_t | argc | ||
) |
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 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 acl::redis_set::sdiff | ( | const std::vector< const char * > & | keys, |
std::vector< string > * | members | ||
) |
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 acl::redis_set::sdiffstore | ( | const char * | dst, |
const std::vector< const char * > & | keys | ||
) |
int acl::redis_set::sdiffstore | ( | const char * | dst, |
const std::vector< string > & | keys | ||
) |
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 acl::redis_set::sinter | ( | const std::vector< const char * > & | keys, |
std::vector< string > * | members | ||
) |
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 acl::redis_set::sinterstore | ( | const char * | dst, |
const std::vector< const char * > & | keys | ||
) |
int acl::redis_set::sinterstore | ( | const char * | dst, |
const std::vector< string > & | keys | ||
) |
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 acl::redis_set::sismember | ( | const char * | key, |
const char * | member, | ||
size_t | len | ||
) |
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. |
操作成功后可以通过以下任一方式获得数据 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
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 acl::redis_set::smove | ( | const char * | src, |
const char * | dst, | ||
const string & | member | ||
) |
int acl::redis_set::smove | ( | const char * | src, |
const char * | dst, | ||
const char * | member, | ||
size_t | len | ||
) |
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 |
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 acl::redis_set::srandmember | ( | const char * | key, |
size_t | n, | ||
std::vector< string > & | out | ||
) |
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 |
int acl::redis_set::srem | ( | const char * | key, |
const std::vector< string > & | members | ||
) |
int acl::redis_set::srem | ( | const char * | key, |
const std::vector< const char * > & | members | ||
) |
int acl::redis_set::srem | ( | const char * | key, |
const char * | members[], | ||
size_t | lens[], | ||
size_t | argc | ||
) |
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 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 acl::redis_set::sunion | ( | const std::vector< const char * > & | keys, |
std::vector< string > * | members | ||
) |
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 acl::redis_set::sunionstore | ( | const char * | dst, |
const std::vector< const char * > & | keys | ||
) |
int acl::redis_set::sunionstore | ( | const char * | dst, |
const std::vector< string > & | keys | ||
) |