acl
3.5.3.0
|
#include <redis_list.hpp>
Public 成员函数 | |
redis_list (void) | |
redis_list (redis_client *conn) | |
redis_list (redis_client_cluster *cluster) | |
ACL_CPP_DEPRECATED | redis_list (redis_client_cluster *cluster, size_t max_conns) |
redis_list (redis_client_pipeline *pipeline) | |
virtual | ~redis_list (void) |
bool | blpop (std::pair< string, string > &result, size_t timeout, const char *first_key,...) |
bool | blpop (const std::vector< const char * > &keys, size_t timeout, std::pair< string, string > &result) |
bool | blpop (const std::vector< string > &keys, size_t timeout, std::pair< string, string > &result) |
bool | brpop (std::pair< string, string > &result, size_t timeout, const char *first_key,...) |
bool | brpop (const std::vector< const char * > &keys, size_t timeout, std::pair< string, string > &result) |
bool | brpop (const std::vector< string > &keys, size_t timeout, std::pair< string, string > &result) |
bool | brpoplpush (const char *src, const char *dst, size_t timeout, string *buf=NULL) |
bool | lindex (const char *key, size_t idx, string &buf) |
int | linsert_before (const char *key, const char *pivot, const char *value) |
int | linsert_before (const char *key, const char *pivot, size_t pivot_len, const char *value, size_t value_len) |
int | linsert_after (const char *key, const char *pivot, const char *value) |
int | linsert_after (const char *key, const char *pivot, size_t pivot_len, const char *value, size_t value_len) |
int | llen (const char *key) |
int | lpop (const char *key, string &buf) |
int | lpush (const char *key, const char *first_value,...) |
int | lpush (const char *key, const char *values[], size_t argc) |
int | lpush (const char *key, const std::vector< string > &values) |
int | lpush (const char *key, const std::vector< const char * > &values) |
int | lpush (const char *key, const char *values[], const size_t lens[], size_t argc) |
int | lpushx (const char *key, const char *value) |
int | lpushx (const char *key, const char *value, size_t len) |
bool | lrange (const char *key, int start, int end, std::vector< string > *result) |
int | lrem (const char *key, int count, const char *value) |
int | lrem (const char *key, int count, const char *value, size_t len) |
bool | lset (const char *key, int idx, const char *value) |
bool | lset (const char *key, int idx, const char *value, size_t len) |
bool | ltrim (const char *key, int start, int end) |
int | rpop (const char *key, string &buf) |
bool | rpoplpush (const char *src, const char *dst, string *buf=NULL) |
int | rpush (const char *key, const char *first_value,...) |
int | rpush (const char *key, const char *values[], size_t argc) |
int | rpush (const char *key, const std::vector< string > &values) |
int | rpush (const char *key, const std::vector< const char * > &values) |
int | rpush (const char *key, const char *values[], const size_t lens[], size_t argc) |
int | rpushx (const char *key, const char *value) |
int | rpushx (const char *key, const char *value, size_t len) |
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_list.hpp 第 10 行定义.
acl::redis_list::redis_list | ( | void | ) |
acl::redis_list::redis_list | ( | redis_client * | conn | ) |
acl::redis_list::redis_list | ( | redis_client_cluster * | cluster | ) |
ACL_CPP_DEPRECATED acl::redis_list::redis_list | ( | redis_client_cluster * | cluster, |
size_t | max_conns | ||
) |
acl::redis_list::redis_list | ( | redis_client_pipeline * | pipeline | ) |
|
virtual |
bool acl::redis_list::blpop | ( | std::pair< string, string > & | result, |
size_t | timeout, | ||
const char * | first_key, | ||
... | |||
) |
从 key 列表对象中弹出一个元素对象(name/value对),采用阻塞方式从头部弹出; 当给定多个 key 参数时,按参数 key 的先后顺序依次检查各个列表,弹出第一个 非空列表的头元素 remove and get a element from list head, or block until one is available; when multiple keys were given, multiple elements will be gotten according the sequence of keys given.
result | {std::pair<string, string>&} 存储结果元素对象,该对象的 第一个字符串表示是列表对象的 key,第二个为该对象的头部元素 store the elements result, the first string of pair is the key, and the second string of pair is the element |
timeout | {size_t} 等待阻塞时间(秒),在超时时间内没有获得元素对象, 则返回 false;如果该值为 0 则一直等待至获得元素对象或出错 the blocking timeout in seconds before one element availble; false will be returned when the timeout is arrived; if the timeout was set to be 0, this function will block until a element was available or some error happened. |
first_key | {const char*} 第一个非空字符串的 key 键,最后一个参数 必须以 NULL 结束,表示变参列表的结束 the first key of a variable args, the last arg must be NULL indicating the end of the variable args. |
bool acl::redis_list::blpop | ( | const std::vector< const char * > & | keys, |
size_t | timeout, | ||
std::pair< string, string > & | result | ||
) |
bool acl::redis_list::blpop | ( | const std::vector< string > & | keys, |
size_t | timeout, | ||
std::pair< string, string > & | result | ||
) |
bool acl::redis_list::brpop | ( | std::pair< string, string > & | result, |
size_t | timeout, | ||
const char * | first_key, | ||
... | |||
) |
含义参见 blpop,唯一区别为该方法弹出尾部元素对象 the meaning is same as the blpop above except that this function is used to pop element from the tail of the list
bool acl::redis_list::brpop | ( | const std::vector< const char * > & | keys, |
size_t | timeout, | ||
std::pair< string, string > & | result | ||
) |
bool acl::redis_list::brpop | ( | const std::vector< string > & | keys, |
size_t | timeout, | ||
std::pair< string, string > & | result | ||
) |
bool acl::redis_list::brpoplpush | ( | const char * | src, |
const char * | dst, | ||
size_t | timeout, | ||
string * | buf = NULL |
||
) |
阻塞式执行以下两个动作: 1) 将列表 src 中的最后一个元素(尾元素)弹出,并返回给客户端。 2) 将 src 弹出的元素插入到列表 dst ,作为 dst 列表的的头元素 two actions will be executed in blocking mode as below: 1) pop a element from src list's tail, and return it to caller 2) push the element to dst list's head
src | {const char*} 源列表对象 key the key of source list |
dst | {const char*} 目标列表对象 key the key of destination list |
buf | {string*} 非空时存储 src 的尾部元素 key 值 if not NULL, buf will store the element poped from the head of src |
timeout | {size_t} 等待超时时间,如果为 0 则一直等待直到有数据或出错 the timeout to wait, if the timeout is 0 this function will block until a element was available or error happened. |
bool acl::redis_list::lindex | ( | const char * | key, |
size_t | idx, | ||
string & | buf | ||
) |
返回 key 对应的列表对象中,指定下标的元素 return the element of the specified subscript from the list at key
key | {const char*} 列表对象的 key the key of one list object |
idx | {size_t} 下标值 the specified subscript |
buf | {string&} 存储结果 store the result |
int acl::redis_list::linsert_after | ( | const char * | key, |
const char * | pivot, | ||
const char * | value | ||
) |
在列表对象中将一个新元素添加至指定元素的后面 append a new element after the specified element in the list
key | {const char*} 列表对象的 key the key of the specified list |
pivot | {const char*} 列表对象中的一个指定元素名 the specified element |
value | {const char*} 新的元素名 the new element @reutrn {int} 返回该列表对象的元素个数,含义如下: return the number of elements in the list specifed by the key: -1 – 表示出错或 key 非列表对象 error happened or it is not a list object specified by key >0 – 当前列表对象的元素个数 the number of elements in list specified by the key |
int acl::redis_list::linsert_after | ( | const char * | key, |
const char * | pivot, | ||
size_t | pivot_len, | ||
const char * | value, | ||
size_t | value_len | ||
) |
int acl::redis_list::linsert_before | ( | const char * | key, |
const char * | pivot, | ||
const char * | value | ||
) |
在列表对象中将一个新元素添加至指定元素的前面 insert one new element before the specified element in list
key | {const char*} 列表对象的 key the key of specified list |
pivot | {const char*} 列表对象中的一个指定元素名 the speicifed element of list |
value | {const char*} 新的元素名 the new element to be inserted @reutrn {int} 返回该列表对象的元素个数,含义如下: return the number of list specified by the given key, as below: -1 – 表示出错或 key 非列表对象 error happened or the object of the key is not a list >0 – 当前列表对象的元素个数 the number of elements of the specified list |
int acl::redis_list::linsert_before | ( | const char * | key, |
const char * | pivot, | ||
size_t | pivot_len, | ||
const char * | value, | ||
size_t | value_len | ||
) |
int acl::redis_list::llen | ( | const char * | key | ) |
返回指定列表对象的元素个数 get the number of elements in list specified the given key
key | {const char*} 列表对象的 key the list's key |
int acl::redis_list::lpop | ( | const char * | key, |
string & | buf | ||
) |
从列表对象中移除并返回头部元素 remove and get the element in the list's head
key | {const char*} 元素对象的 key the key of one list |
buf | {string&} 存储弹出的元素值 store the element when successful. |
int acl::redis_list::lpush | ( | const char * | key, |
const char * | first_value, | ||
... | |||
) |
将一个或多个值元素插入到列表对象 key 的表头 add one or more element(s) to the head of a list
key | {const char*} 列表对象的 key the list key |
first_value | {const char*} 第一个非空字符串,该变参的列表的最后一个 必须设为 NULL the first no-NULL element of the variable args, the last arg must be NULL indicating the end of the args. |
int acl::redis_list::lpush | ( | const char * | key, |
const char * | values[], | ||
size_t | argc | ||
) |
int acl::redis_list::lpush | ( | const char * | key, |
const std::vector< string > & | values | ||
) |
int acl::redis_list::lpush | ( | const char * | key, |
const std::vector< const char * > & | values | ||
) |
int acl::redis_list::lpush | ( | const char * | key, |
const char * | values[], | ||
const size_t | lens[], | ||
size_t | argc | ||
) |
int acl::redis_list::lpushx | ( | const char * | key, |
const char * | value | ||
) |
将一个新的列表对象的元素添加至已经存在的指定列表对象的头部,当该列表对象 不存在时则不添加 add a new element before the head of a list, only if the list exists
key | {const char*} 列表对象的 key the list's key |
value | {const char*} 新加的列表对象的元素 the new element to be added |
int acl::redis_list::lpushx | ( | const char * | key, |
const char * | value, | ||
size_t | len | ||
) |
bool acl::redis_list::lrange | ( | const char * | key, |
int | start, | ||
int | end, | ||
std::vector< string > * | result | ||
) |
返回列表 key 中指定区间内(闭区间)的元素,区间以偏移量 start 和 end 指定; 下标起始值从 0 开始,-1 表示最后一个下标值 get a range of elements from list, the range is specified by start and end, and the start begins with 0, -1 means the end
key | {const char*} 列表对象的 key the specified key of one list |
start | {int} 起始下标值 the start subscript of list |
end | {int} 结束下标值 the end subscript of list |
result | {std::vector<string>*} 非空时存储列表对象中指定区间的元素集合 if not NULL, result will be used to store the results |
操作成功后可以通过以下任一方式获得数据 the result can be got by one of the ways as below:
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.
int acl::redis_list::lrem | ( | const char * | key, |
int | count, | ||
const char * | value | ||
) |
根据元素值从列表对象中移除指定数量的元素 remove the first count occurrences of elements equal to value from the list stored at key
key | {const char*} 列表对象的 key the key of a list |
count | {int} 移除元素的数量限制,count 的含义如下: the first count of elements to be removed, as below: count > 0 : 从表头开始向表尾搜索,移除与 value 相等的元素,数量为 count remove elements equal to value moving from head to tail count < 0 : 从表尾开始向表头搜索,移除与 value 相等的元素,数量为 count 的绝对值 remove elements equal to value moving from tail to head count = 0 : 移除表中所有与 value 相等的值 remove all elements equal to value |
value | {const char*} 指定的元素值,需要从列表对象中遍历所有与该值比较 the specified value for removing elements |
int acl::redis_list::lrem | ( | const char * | key, |
int | count, | ||
const char * | value, | ||
size_t | len | ||
) |
bool acl::redis_list::lset | ( | const char * | key, |
int | idx, | ||
const char * | value | ||
) |
将列表 key 下标为 idx 的元素的值设置为 value,当 idx 参数超出范围,或对 一个空列表( key 不存在)进行 lset 时,返回一个错误 set the value of a element in a list by its index, if the index out of bounds or the key of list not exist, an error will happen.
key | {const char*} 列表对象的 key the key of list |
idx | {int} 下标位置,当为负值时则从尾部向头尾部定位,否则采用顺序方式; 如:0 表示头部第一个元素,-1 表示尾部开始的第一个元素 the index in the list, if it's negative, iterating data will be from tail to head, or be from head to tail. |
value | {const char*} 元素新值 the new value of the element by its index |
bool acl::redis_list::lset | ( | const char * | key, |
int | idx, | ||
const char * | value, | ||
size_t | len | ||
) |
bool acl::redis_list::ltrim | ( | const char * | key, |
int | start, | ||
int | end | ||
) |
对指定的列表对象,对一个列表进行修剪,让列表只保留指定区间内的元素, 不在指定区间之内的元素都将被删除;区间以偏移量 start 和 end 指定; 下标起始值从 0 开始,-1 表示最后一个下标值 remove elements in a list by range betwwen start and end.
key | {const char*} 列表对象的 key the key of a list |
start | {int} 起始下标值 the start index in a list |
end | {int} 结束下标值 the end index in a list |
int acl::redis_list::rpop | ( | const char * | key, |
string & | buf | ||
) |
从列表对象中移除并返回尾部元素 remove and get the last element of a list
key | {const char*} 元素对象的 key the key of the list |
buf | {string&} 存储弹出的元素值 store the element pop from list |
bool acl::redis_list::rpoplpush | ( | const char * | src, |
const char * | dst, | ||
string * | buf = NULL |
||
) |
在一个原子时间内,非阻塞方式执行以下两个动作: 将列表 src 中的最后一个元素(尾元素)弹出,并返回给客户端。 将 src 弹出的元素插入到列表 dst ,作为 dst 列表的的头元素 remove the last element in a list, prepend it to another list and return it.
src | {const char*} 源列表对象 key the key of the source list |
dst | {const char*} 目标列表对象 key the key of the destination list |
buf | {string*} 非空时存储 src 的尾部元素 key 值 if not NULL, it will store the element |
int acl::redis_list::rpush | ( | const char * | key, |
const char * | first_value, | ||
... | |||
) |
将一个或多个值元素插入到列表对象 key 的表尾 append one or multiple values to a list
key | {const char*} 列表对象的 key the key of a list |
first_value | {const char*} 第一个非空字符串,该变参的列表的最后一个 必须设为 NULL the first element of a variable args must be not NULL, and the last arg must be NULL indicating the end of the args. |
int acl::redis_list::rpush | ( | const char * | key, |
const char * | values[], | ||
size_t | argc | ||
) |
int acl::redis_list::rpush | ( | const char * | key, |
const std::vector< string > & | values | ||
) |
int acl::redis_list::rpush | ( | const char * | key, |
const std::vector< const char * > & | values | ||
) |
int acl::redis_list::rpush | ( | const char * | key, |
const char * | values[], | ||
const size_t | lens[], | ||
size_t | argc | ||
) |
int acl::redis_list::rpushx | ( | const char * | key, |
const char * | value | ||
) |
将一个新的列表对象的元素添加至已经存在的指定列表对象的尾部,当该列表对象 不存在时则不添加 append one or multiple values to a list only if the list exists.
key | {const char*} 列表对象的 key the key of a list |
value | {const char*} 新加的列表对象的元素 the new element to be added. |
int acl::redis_list::rpushx | ( | const char * | key, |
const char * | value, | ||
size_t | len | ||
) |