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

120 lines
4.4 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;
class ACL_CPP_API redis_hash : public redis_command
2015-01-14 23:35:23 +08:00
{
public:
redis_hash(redis_client* conn = NULL);
2015-01-14 23:35:23 +08:00
~redis_hash();
/////////////////////////////////////////////////////////////////////
/**
* <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>
* @param key {const char*} KEY ֵ
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
bool hmset(const char* key, const std::map<string, string>& attrs);
bool hmset(const char* key, const std::map<string, char*>& attrs);
bool hmset(const char* key, const std::map<string, const char*>& attrs);
bool hmset(const char* key, const std::map<int, string>& attrs);
bool hmset(const char* key, const std::map<int, char*>& attrs);
bool hmset(const char* key, const std::map<int, const char*>& attrs);
/////////////////////////////////////////////////////////////////////
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<EFBFBD><EFBFBD>"<EFBFBD>Դӹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>
* @param key {const char*} KEY ֵ
* @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> hmget_result <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>±<EFBFBD>ֵȡ<EFBFBD>ö<EFBFBD>Ӧ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD> get_result <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD> redis_result
*/
bool hmget(const char* key, const std::vector<string>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const std::vector<char*>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const std::vector<const char*>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const std::vector<int>& 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 int 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
/**
* <EFBFBD><EFBFBD> hmget <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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> hmget <EFBFBD>е<EFBFBD><E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BFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>ʱ
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD>β<EFBFBD><EFBFBD>
*/
const char* hmget_value(size_t i, size_t* len = NULL) const;
const redis_result* hmget_child(size_t i) const;
size_t hmget_size() const;
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);
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);
bool hget(const char* key, const char* name, string& result);
bool hget(const char* key, const char* name,
size_t name_len, string& result);
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);
int hdel(const char* key, const char* first_name, ...)
ACL_CPP_PRINTF(3, 4);;
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<char*>& names);
int hdel(const char* key, const std::vector<const char*>& names);
bool hincrby(const char* key, const char* name,
long long int inc, long long int* result = NULL);
bool hincrbyfloat(const char* key, const char* name,
double inc, double* result = NULL);
bool hkeys(const char* key, std::vector<string>& names);
bool hexists(const char* key, const char* name);
bool hexists(const char* key, const char* name, size_t name_len);
int hlen(const char* key);
};
} // namespace acl