acl/lib_acl_cpp/include/acl_cpp/redis/redis_hash.hpp

338 lines
13 KiB
C++
Raw Normal View History

2015-01-14 23:35:23 +08:00
#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include <map>
#include <vector>
#include "acl_cpp/stdlib/string.hpp"
#include "acl_cpp/redis/redis_command.hpp"
2015-01-14 23:35:23 +08:00
namespace acl
{
class redis_client;
class redis_result;
2015-01-26 19:58:02 +08:00
/**
2015-04-12 21:37:17 +08:00
* redis Hash(<EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>
* redis Hash class, include commands as below:
2015-01-26 19:58:02 +08:00
* HDEL/HEXISTS/HGET/HGETALL/HINCRBY/HINCRBYFLOAT/HKEYS/HLEN/HMGET/HMSET
* HSET/HSETNX/HVALS/HSCAN
*/
class ACL_CPP_API redis_hash : virtual public redis_command
2015-01-14 23:35:23 +08:00
{
public:
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command()
*/
redis_hash(void);
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command(redis_client*)
*/
redis_hash(redis_client* conn);
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command(redis_client_cluster*<EFBFBD><EFBFBD> size_t)
2015-03-29 19:27:41 +08:00
*/
redis_hash(redis_client_cluster* cluster, size_t max_conns = 0);
2015-03-29 19:27:41 +08:00
virtual ~redis_hash(void);
2015-01-14 23:35:23 +08:00
/////////////////////////////////////////////////////////////////////
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<EFBFBD><EFBFBD>"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY <EFBFBD><EFBFBD>Ӧ<EFBFBD>Ĺ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* HMSET: set the key's multiple fileds in redis-server
2015-01-26 19:58:02 +08:00
* @param key {const char*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD> key ֵ
2015-04-12 21:37:17 +08:00
* the hash key for Hash class
* @param attrs {const std::map<acl::string, ...>&} the fileds in map
2015-01-14 23:35:23 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
2015-04-12 21:37:17 +08:00
* if successful for HMSET command
2015-01-14 23:35:23 +08:00
*/
bool hmset(const char* key, const std::map<string, string>& attrs);
bool hmset(const char* key, const std::map<string, const char*>& attrs);
/////////////////////////////////////////////////////////////////////
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<EFBFBD><EFBFBD>"<EFBFBD>Դӹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* get the values associated with the specified fields
* in the hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD> key ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param names <EFBFBD><EFBFBD>Ӧ key <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the given hash fileds
* @param result {std::vector<acl::string>*} <EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>Ϊ NULL ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> result_/get_ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* store the result of the given hash files if not NULL.
* If NULL, the base class's method like result_/get can be used
* to get the values
2015-01-30 22:58:13 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ַ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>
2015-04-12 21:37:17 +08:00
* if successul, one of below ways can be used to get the result:
*
* 1<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿյĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
* input the no-NULL result parameter when call hmget, when
* success, the result will store the values of the given fileds
*
* 2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> result_value <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* call redis_command::result_value with the specified subscript
*
* 3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> result_child <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>(redis_result<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
2015-01-30 22:58:13 +08:00
* redis_result::argv_to_string <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* call redis_command::result_child with specified subscript to
* get redis_result object, then call redis_result::argv_to_string
* with above result to get the values of the give fileds
*
* 4<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> get_result <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis_result<EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
2015-01-30 22:58:13 +08:00
* redis_result::get_child <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>Ԫ<EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ 2 <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
* <EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>Ԫ<EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* call redis_command::get_result with the specified subscript to
* get redis_result object, and use redis_result::get_child to
* get one result object, then call redis_result::argv_to_string
* to get the value of one filed.
*
* 5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> get_children <EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> redis_result <EFBFBD><EFBFBD>
2015-01-30 22:58:13 +08:00
* <EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD> argv_to_string <EFBFBD><EFBFBD>ÿһ<EFBFBD><EFBFBD>Ԫ<EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* use redis_command::get_children to get the redis_result array,
* then use redis_result::argv_to_string to get every value of
* the given fileds
2015-01-14 23:35:23 +08:00
*/
bool hmget(const char* key, const std::vector<string>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const std::vector<const char*>& names,
std::vector<string>* result = NULL);
2015-01-14 23:35:23 +08:00
bool hmget(const char* key, const char* names[], size_t argc,
std::vector<string>* result = NULL);
bool hmget(const char* key, const char* names[], const size_t lens[],
size_t argc, std::vector<string>* result = NULL);
2015-01-14 23:35:23 +08:00
/////////////////////////////////////////////////////////////////////
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* set one field's value in the hash stored at key.
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param name {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the filed name of the hash key
2015-01-26 19:58:02 +08:00
* @param value {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the filed value of the hash key
2015-01-26 19:58:02 +08:00
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>
* 1 -- <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>
* 0 -- <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶγɹ<EFBFBD>
* -1 -- <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>޸<EFBFBD>
2015-04-12 21:37:17 +08:00
* return int value as below:
* 1 -- this is a new filed and set ok
* 0 -- thie is a old filed and set ok
* -1 -- error happend or the key is not a Hash type
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
int hset(const char* key, const char* name, const char* value);
int hset(const char* key, const char* name,
const char* value, size_t value_len);
int hset(const char* key, const char* name, size_t name_len,
const char* value, size_t value_len);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ÿ<EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* set one new field of one key in hash only when the filed isn't
* existing.
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param name {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the field name
2015-01-26 19:58:02 +08:00
* @param value {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
*<EFBFBD><EFBFBD>the field value
2015-01-26 19:58:02 +08:00
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>
* 1 -- <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>
* 0 -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶδ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>
* -1 -- <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>޸<EFBFBD>
2015-04-12 21:37:17 +08:00
*
* return int value as below:
* 1 -- this is a new filed and set ok
* 0 -- thie is a old filed and not set
* -1 -- error happend or the key is not a Hash type
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
int hsetnx(const char* key, const char* name, const char* value);
int hsetnx(const char* key, const char* name,
const char* value, size_t value_len);
int hsetnx(const char* key, const char* name, size_t name_len,
const char* value, size_t value_len);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>ȡij<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* get the value assosiated with field in the hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param name {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the field's name
* @param result {acl::string&} <EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ(<EFBFBD>ڲ<EFBFBD><EFBFBD>Ը<EFBFBD> string <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷<EFBFBD><EFBFBD>)
* store the value result of the given field
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* true -- <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ
* get the value associated with field
* false -- <EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* the field not exists, or error happened,
* or the key isn't a hash key
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
bool hget(const char* key, const char* name, string& result);
bool hget(const char* key, const char* name,
size_t name_len, string& result);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>ȡij<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* get all the fields and values in hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param result {std::map<string, string>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>-ֵ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* store the result of all the fileds and values
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* if ok, show below:
2015-01-26 19:58:02 +08:00
* true -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򲻴<EFBFBD><EFBFBD><EFBFBD>ʱҲ<EFBFBD><EFBFBD><EFBFBD>سɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> result <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> result.size() <EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* successful if the key is a hash key or the key not exists
2015-01-26 19:58:02 +08:00
* false -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* error happened or the key isn't a hash key
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
bool hgetall(const char* key, std::map<string, string>& result);
bool hgetall(const char* key, std::vector<string>& names,
std::vector<string>& values);
bool hgetall(const char* key, std::vector<const char*>& names,
std::vector<const char*>& values);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijЩ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
2015-04-12 21:37:17 +08:00
* remove one or more fields from hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param first_name {const char*} <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֶα<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL
2015-04-12 21:37:17 +08:00
* the first field of the fields list, the last field must be NULL
* indicating the end of vary parameters
2015-01-26 19:58:02 +08:00
* @return {int} <EFBFBD>ɹ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶθ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* return the number of fields be removed successfully, or -1 when
* error happened or operating on a no hash key
2015-01-26 19:58:02 +08:00
*/
int hdel(const char* key, const char* first_name);
2015-01-14 23:35:23 +08:00
int hdel(const char* key, const char* names[], size_t argc);
int hdel(const char* key, const char* names[],
const size_t names_len[], size_t argc);
int hdel(const char* key, const std::vector<string>& names);
int hdel(const char* key, const std::vector<const char*>& names);
int hdel_fields(const char* key, const char* names[], size_t argc);
int hdel_fields(const char* key, const char* names[],
const size_t names_len[], size_t argc);
int hdel_fields(const char* key, const std::vector<string>& names);
int hdel_fields(const char* key, const std::vector<const char*>& names);
int hdel_fields(const char* key, const char* first_name, ...);
2015-01-14 23:35:23 +08:00
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>мӼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* inc(+n) or dec(-n) on a integer filed in hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param name {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the filed name of integer type
2015-01-26 19:58:02 +08:00
* @param inc {long long int} <EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the integer value to be inc or dec on the field's value
2015-01-26 19:58:02 +08:00
* @param result {long long int*} <EFBFBD><EFBFBD> NULL ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* store the result if non-NULL
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶη<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* if successful: false when error, not a hash, or the field isn't
* integer type
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
bool hincrby(const char* key, const char* name,
long long int inc, long long int* result = NULL);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>мӼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* inc(+n) or dec(-n) on a float filed in hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param name {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the filed name of float type
2015-01-26 19:58:02 +08:00
* @param inc {double} <EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the float value to be inc or dec on the field's value
2015-01-26 19:58:02 +08:00
* @param result {double*} <EFBFBD><EFBFBD> NULL ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* store the result if non-NULL
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶηǸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* if successful: false when error, not a hash, or the field isn't
* float type
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
bool hincrbyfloat(const char* key, const char* name,
double inc, double* result = NULL);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* get all the fields in hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param names {std::vector<string>&} <EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* store all the names of all fileds
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* return true on success, false if error happened or the
* key wasn't a hash key
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
bool hkeys(const char* key, std::vector<string>& names);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* check if the field exists in hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @param name {const char*} key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the filed's name of the key
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* return true on success, false if error happened or the
* key wasn't a hash key
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
bool hexists(const char* key, const char* name);
bool hexists(const char* key, const char* name, size_t name_len);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* get the count of fields in hash stored at key
2015-01-26 19:58:02 +08:00
* @param key {const char*} key <EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-26 19:58:02 +08:00
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* return int value as below:
2015-01-26 19:58:02 +08:00
* -1 -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* error or not a hash key
2015-01-26 19:58:02 +08:00
* >0 -- <EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the count of fields
2015-01-26 19:58:02 +08:00
* 0 -- <EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 0
2015-04-12 21:37:17 +08:00
* key not exists or no fields in hash stored at key
2015-01-26 19:58:02 +08:00
*/
2015-01-14 23:35:23 +08:00
int hlen(const char* key);
2015-01-23 17:23:04 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>еļ<EFBFBD>ֵ<EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* scan the name and value of all fields in hash stored at key
2015-01-23 17:23:04 +08:00
* @param key {const char*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ
2015-04-12 21:37:17 +08:00
* the hash key
2015-01-23 17:23:04 +08:00
* @param cursor {int} <EFBFBD>α<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ֵд 0
2015-04-12 21:37:17 +08:00
* the cursor value, which is 0 at begin
* @param out {std::map<acl::string>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>׷<EFBFBD>ӷ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>Ϊ<EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* store scaning result in appending mode
2015-01-23 17:23:04 +08:00
* @param pattern {const char*} ƥ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>glob <EFBFBD><EFBFBD><EFBFBD>񣬷ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ч
2015-04-12 21:37:17 +08:00
* match pattern, effective only on no-NULL
2015-01-23 17:23:04 +08:00
* @param count {const size_t*} <EFBFBD>޶<EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ָ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ч
2015-04-12 21:37:17 +08:00
* the max count of one scan process, effective only on no-NULL
2015-01-23 17:23:04 +08:00
* @return {int} <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>α<EFBFBD>λ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
2015-04-12 21:37:17 +08:00
* return the next cursor position, as below:
2015-01-23 17:23:04 +08:00
* 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* scan finish
2015-01-23 17:23:04 +08:00
* -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* some error happened
* >0: <EFBFBD>α<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ٽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> out<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>п<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
2015-04-12 21:37:17 +08:00
* the next cursor postion to scan
2015-01-23 17:23:04 +08:00
*/
int hscan(const char* key, int cursor, std::map<string, string>& out,
const char* pattern = NULL, const size_t* count = NULL);
2015-01-14 23:35:23 +08:00
};
} // namespace acl