acl
3.5.3.0
|
#include <redis_key.hpp>
Public 成员函数 | |
redis_key (void) | |
redis_key (redis_client *conn) | |
redis_key (redis_client_cluster *cluster) | |
ACL_CPP_DEPRECATED | redis_key (redis_client_cluster *cluster, size_t max_conns) |
redis_key (redis_client_pipeline *pipeline) | |
virtual | ~redis_key (void) |
int | del_one (const char *key) |
int | del_one (const char *key, size_t len) |
int | del (const char *key) |
int | del (const std::vector< string > &keys) |
int | del (const std::vector< const char * > &keys) |
int | del (const char *keys[], size_t argc) |
int | del (const char *keys[], const size_t lens[], size_t argc) |
int | del_keys (const char *first_key,...) |
int | del_keys (const std::vector< string > &keys) |
int | del_keys (const std::vector< const char * > &keys) |
int | del_keys (const char *keys[], size_t argc) |
int | del_keys (const char *keys[], const size_t lens[], size_t argc) |
int | dump (const char *key, size_t len, string &out) |
int | dump (const char *key, string &out) |
bool | exists (const char *key, size_t len) |
bool | exists (const char *key) |
int | expire (const char *key, size_t len, int n) |
int | expire (const char *key, int n) |
int | expireat (const char *key, size_t len, time_t stamp) |
int | expireat (const char *key, time_t stamp) |
int | keys_pattern (const char *pattern, std::vector< string > *out) |
bool | migrate (const char *key, size_t len, const char *addr, unsigned dest_db, unsigned timeout, const char *option=NULL) |
bool | migrate (const char *key, const char *addr, unsigned dest_db, unsigned timeout, const char *option=NULL) |
int | move (const char *key, size_t len, unsigned dest_db) |
int | move (const char *key, unsigned dest_db) |
int | object_refcount (const char *key, size_t len) |
int | object_refcount (const char *key) |
bool | object_encoding (const char *key, size_t len, string &out) |
bool | object_encoding (const char *key, string &out) |
int | object_idletime (const char *key, size_t len) |
int | object_idletime (const char *key) |
int | persist (const char *key, size_t len) |
int | persist (const char *key) |
int | pexpire (const char *key, size_t len, int n) |
int | pexpire (const char *key, int n) |
int | pexpireat (const char *key, size_t len, long long int n) |
int | pexpireat (const char *key, long long int n) |
long long int | pttl (const char *key, size_t len) |
long long int | pttl (const char *key) |
bool | randomkey (string &buf) |
bool | rename_key (const char *key, const char *newkey) |
int | renamenx (const char *key, const char *newkey) |
bool | restore (const char *key, const char *value, size_t len, int ttl, bool replace=false) |
int | ttl (const char *key, size_t len) |
int | ttl (const char *key) |
redis_key_t | type (const char *key, size_t len) |
redis_key_t | type (const char *key) |
int | scan (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_key.hpp 第 23 行定义.
acl::redis_key::redis_key | ( | void | ) |
acl::redis_key::redis_key | ( | redis_client * | conn | ) |
acl::redis_key::redis_key | ( | redis_client_cluster * | cluster | ) |
ACL_CPP_DEPRECATED acl::redis_key::redis_key | ( | redis_client_cluster * | cluster, |
size_t | max_conns | ||
) |
acl::redis_key::redis_key | ( | redis_client_pipeline * | pipeline | ) |
|
virtual |
int acl::redis_key::del | ( | const char * | key | ) |
int acl::redis_key::del | ( | const std::vector< string > & | keys | ) |
int acl::redis_key::del | ( | const std::vector< const char * > & | keys | ) |
int acl::redis_key::del | ( | const char * | keys[], |
size_t | argc | ||
) |
int acl::redis_key::del | ( | const char * | keys[], |
const size_t | lens[], | ||
size_t | argc | ||
) |
int acl::redis_key::del_keys | ( | const char * | first_key, |
... | |||
) |
int acl::redis_key::del_keys | ( | const std::vector< string > & | keys | ) |
int acl::redis_key::del_keys | ( | const std::vector< const char * > & | keys | ) |
int acl::redis_key::del_keys | ( | const char * | keys[], |
size_t | argc | ||
) |
int acl::redis_key::del_keys | ( | const char * | keys[], |
const size_t | lens[], | ||
size_t | argc | ||
) |
int acl::redis_key::del_one | ( | const char * | key | ) |
删除一个或一组 KEY,对于变参的接口,则要求最后一个参数必须以 NULL 结束 delete one or some keys from redis, for deleting a variable number of keys, the last key must be NULL indicating the end of the variable args
int acl::redis_key::del_one | ( | const char * | key, |
size_t | len | ||
) |
int acl::redis_key::dump | ( | const char * | key, |
size_t | len, | ||
string & | out | ||
) |
序列化给定 key ,并返回被序列化的值,使用 RESTORE 命令可以将这个值反序列化 为 Redis 键 serialize the object associate with the given key, and get the value after serializing, RESTORE command can be used to deserialize by the value
key | {const char*} 键值 the key |
len | {size_t} key 长度 the key's length |
out | {string&} 存储序列化的二进制数据 buffur used to store the result |
int acl::redis_key::dump | ( | const char * | key, |
string & | out | ||
) |
bool acl::redis_key::exists | ( | const char * | key, |
size_t | len | ||
) |
判断 KEY 是否存在 check if the key exists in redis
key | {const char*} KEY 值 the key |
len | {size_t} key 长度 the key's length |
bool acl::redis_key::exists | ( | const char * | key | ) |
int acl::redis_key::expire | ( | const char * | key, |
size_t | len, | ||
int | n | ||
) |
设置 KEY 的生存周期,单位(秒) set a key's time to live in seconds
key | {const char*} 键值 the key |
len | {size_t} key 长度 the key's length |
n | {int} 生存周期(秒) lief cycle in seconds |
set successfully 0:该 key 不存在 the key doesn't exist < 0: 出错 error happened0: 成功设置了生存周期
int acl::redis_key::expire | ( | const char * | key, |
int | n | ||
) |
int acl::redis_key::expireat | ( | const char * | key, |
size_t | len, | ||
time_t | stamp | ||
) |
用 UNIX 时间截设置 KEY 的生存周期 set the expiration for a key as a UNIX timestamp
key | {const char*} 对象键值 the key |
len | {size_t} key 长度 the key's length |
stamp | {time_t} UNIX 时间截,即自 1970 年以来的秒数 an absolute Unix timestamp (seconds since January 1, 1970). |
int acl::redis_key::expireat | ( | const char * | key, |
time_t | stamp | ||
) |
int acl::redis_key::keys_pattern | ( | const char * | pattern, |
std::vector< string > * | out | ||
) |
查找所有符合给定模式 pattern 的 key find all keys matching the given pattern
pattern | {const char*} 匹配模式 the give matching pattern |
out | {std::vector<string>*} 非 NULL 时用来存储结果集 store the matched keys |
操作成功后可以通过以下任一方式获得数据 1、基类方法 get_value 获得指定下标的元素数据 2、基类方法 get_child 获得指定下标的元素对象(redis_result),然后 再通过 redis_result::argv_to_string 方法获得元素数据 3、基类方法 get_result 方法取得总结果集对象 redis_result,然后再 通过 redis_result::get_child 获得一个元素对象,然后再通过方式 2 中指定的方法获得该元素的数据 4、基类方法 get_children 获得结果元素数组对象,再通过 redis_result 中的方法 argv_to_string 从每一个元素对象中获得元素数据 5、在调用方法中传入非空的存储结果对象的地址
bool acl::redis_key::migrate | ( | const char * | key, |
size_t | len, | ||
const char * | addr, | ||
unsigned | dest_db, | ||
unsigned | timeout, | ||
const char * | option = NULL |
||
) |
将数据从一个 redis-server 迁移至另一个 redis-server atomically transfer a key from a redis instance to another one
key | {const char*} 数据对应的键值 the key |
len | {size_t} key 长度 the key's length |
addr | {const char*} 目标 redis-server 服务器地址,格式:ip:port the destination redis instance's address, format: ip:port |
dest_db | {unsigned} 目标 redis-server 服务器的数据库 ID 号 the databases ID in destination redis |
timeout | {unsigned} 迁移过程的超时时间(毫秒级) timeout(microseconds) in transfering |
option | {const char*} COPY 或 REPLACE transfer option: COPY or REPLACE |
bool acl::redis_key::migrate | ( | const char * | key, |
const char * | addr, | ||
unsigned | dest_db, | ||
unsigned | timeout, | ||
const char * | option = NULL |
||
) |
int acl::redis_key::move | ( | const char * | key, |
size_t | len, | ||
unsigned | dest_db | ||
) |
将数据移至本 redis-server 中的另一个数据库中 move a key to another database
key | {const char*} 数据键值 the key |
len | {size_t} key 长度 the key's length |
dest_db | {unsigned} 目标数据库 ID 号 the destination database |
int acl::redis_key::move | ( | const char * | key, |
unsigned | dest_db | ||
) |
bool acl::redis_key::object_encoding | ( | const char * | key, |
size_t | len, | ||
string & | out | ||
) |
返回给定 key 键储存的值所使用的内部表示 get the internal storing of the object assosicate with the key
key | {const char*} 数据键值 the key |
len | {size_t} key 长度 |
out | {string&} 存在结果 store the result |
bool acl::redis_key::object_encoding | ( | const char * | key, |
string & | out | ||
) |
int acl::redis_key::object_idletime | ( | const char * | key, |
size_t | len | ||
) |
返回给定 key 自储存以来的空闲时间(idle, 没有被读取也没有被写入),以秒为单位 get the key's idle time in seconds since its first stored
key | {const char*} 数据键值 the key |
len | {size_t} key 长度 the key's length |
int acl::redis_key::object_idletime | ( | const char * | key | ) |
int acl::redis_key::object_refcount | ( | const char * | key, |
size_t | len | ||
) |
返回给定 key 引用所储存的值的次数。此命令主要用于除错。 get the referring count of the object, which just for debugging
key | {const char*} 数据键值 the key |
len | {size_t} key 长度 the key's length |
int acl::redis_key::object_refcount | ( | const char * | key | ) |
int acl::redis_key::persist | ( | const char * | key, |
size_t | len | ||
) |
移除给定 key 的生存时间,将这个 key 从"易失的"(带生存时间 key )转换成 "持久的"(一个不带生存时间、永不过期的 key ) remove the expiration from a key
key | {const char*} 对象键值 the key |
len | {size_t} key 长度 the key's length |
int acl::redis_key::persist | ( | const char * | key | ) |
int acl::redis_key::pexpire | ( | const char * | key, |
size_t | len, | ||
int | n | ||
) |
设置 KEY 的生存周期,单位(毫秒) set a key's time to live in milliseconds
key | {const char*} 键值 the key |
len | {size_t} key 长度 the key's length |
n | {int} 生存周期(毫秒) time to live in milliseconds |
set successfully 0:该 key 不存在 the key doesn't exist < 0: 出错 error happened0: 成功设置了生存周期
int acl::redis_key::pexpire | ( | const char * | key, |
int | n | ||
) |
int acl::redis_key::pexpireat | ( | const char * | key, |
size_t | len, | ||
long long int | n | ||
) |
以毫秒为单位设置 key 的过期 unix 时间戳 set the expiration for a key as UNIX timestamp specified in milliseconds
key | {const char*} 键值 the key |
len | {size_t} key 长度 the key's length |
n | {long long int} UNIX 时间截,即自 1970 年以来的毫秒数 the UNIX timestamp in milliseconds from 1970.1.1 |
set successfully 0:该 key 不存在 the key doesn't exist < 0: 出错 error happened0: 成功设置了生存周期
int acl::redis_key::pexpireat | ( | const char * | key, |
long long int | n | ||
) |
long long int acl::redis_key::pttl | ( | const char * | key, |
size_t | len | ||
) |
获得 KEY 的剩余生存周期,单位(毫秒) get the time to live for a key in milliseconds
key | {const char*} 键值 the key |
len | {size_t} key 长度 the key's length |
long long int acl::redis_key::pttl | ( | const char * | key | ) |
bool acl::redis_key::randomkey | ( | string & | buf | ) |
从当前数据库中随机返回(不会删除)一个 key return a random key from the keyspace *
buf | {string&} 成功获得随机 KEY 时存储结果 store the key |
bool acl::redis_key::rename_key | ( | const char * | key, |
const char * | newkey | ||
) |
将 key 改名为 newkey rename a key
int acl::redis_key::renamenx | ( | const char * | key, |
const char * | newkey | ||
) |
当且仅当 newkey 不存在时,将 key 改名为 newkey rename a key only if the new key does not exist
key | {const char*} 旧 key |
newkey | {const char*} 新 key |
bool acl::redis_key::restore | ( | const char * | key, |
const char * | value, | ||
size_t | len, | ||
int | ttl, | ||
bool | replace = false |
||
) |
反序列化给定的序列化值,并将它和给定的 key 关联 create a key using the provided serialized value, previously obtained by using DUMP
ttl | {int} 以毫秒为单位为 key 设置生存时间,如果 ttl 为 0, 那么不设置生存时间 the time to live for the key in milliseconds, if tll is 0, expiration will not be set |
replace | {bool} 如果 key 存在是否直接覆盖 if the key already exists, this parameter decides if replacing the existing key |
int acl::redis_key::scan | ( | int | cursor, |
std::vector< string > & | out, | ||
const char * | pattern = NULL , |
||
const size_t * | count = NULL |
||
) |
命令用于迭代当前数据库中的数据库键 incrementally iterate the keys space in the specified database
cursor | {int} 游标值,开始遍历时该值写 0 the iterating cursor beginning with 0 |
out | {std::vector<acl::string>&} 存储结果集,内部以追加方式将本次 遍历结果集合添加进该数组中,为防止因总结果集过大导致该数组溢出,用户可在 调用本函数前后清理该数组对象 string array storing the results, the array will be cleared internal and the string result will be appened to the array |
pattern | {const char*} 匹配模式,glob 风格,非空时有效 & the matching pattern with glob style, only effective if not NULL |
count | {const size_t*} 限定的结果集数量,非空指针时有效 limit the max number of the results stored in array, only effective when not NULL |
int acl::redis_key::ttl | ( | const char * | key, |
size_t | len | ||
) |
获得 KEY 的剩余生存周期,单位(秒) get the time to live for a key in seconds
key | {const char*} 键值 the key |
len | {size_t} key 长度 the key's length |
the time to live for a key in seconds -3:出错 error happened -2:key 不存在 the key doesn't exist -1:当 key 存在但没有设置剩余时间 the key were not be set expiration 注:对于 redis-server 2.8 以前版本,key 不存在或存在但未设置生存期则返回 -1 notice: for the redis version before 2.8, -1 will be returned if the key doesn't exist or the key were not be set expiration0: 该 key 剩余的生存周期(秒)
int acl::redis_key::ttl | ( | const char * | key | ) |
redis_key_t acl::redis_key::type | ( | const char * | key, |
size_t | len | ||
) |
获得 KEY 的存储类型 get the the type stored at key @para key {const char*} KEY 值 the key
len | {size_t} key 长度 the key's length |
redis_key_t acl::redis_key::type | ( | const char * | key | ) |