mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-14 08:50:53 +08:00
132 lines
4.4 KiB
C++
132 lines
4.4 KiB
C++
|
#pragma once
|
|||
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|||
|
#include <map>
|
|||
|
#include <vector>
|
|||
|
#include "acl_cpp/stdlib/string.hpp"
|
|||
|
|
|||
|
namespace acl
|
|||
|
{
|
|||
|
|
|||
|
class redis_client;
|
|||
|
class redis_result;
|
|||
|
|
|||
|
class ACL_CPP_API redis_hash
|
|||
|
{
|
|||
|
public:
|
|||
|
redis_hash(redis_client& conn);
|
|||
|
~redis_hash();
|
|||
|
|
|||
|
const redis_result* get_result() const
|
|||
|
{
|
|||
|
return result_;
|
|||
|
}
|
|||
|
|
|||
|
redis_client& get_client() const
|
|||
|
{
|
|||
|
return conn_;
|
|||
|
}
|
|||
|
|
|||
|
/////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
/**
|
|||
|
* <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);
|
|||
|
bool hmset(const string& req);
|
|||
|
|
|||
|
/////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
/**
|
|||
|
* <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);
|
|||
|
bool hmget(const char* key, const std::vector<char*>& names);
|
|||
|
bool hmget(const char* key, const std::vector<const char*>& names);
|
|||
|
bool hmget(const char* key, const std::vector<int>& names);
|
|||
|
|
|||
|
bool hmget(const char* key, const char* names[], size_t argc);
|
|||
|
bool hmget(const char* key, const int names[], size_t argc);
|
|||
|
bool hmget(const char* key, const char* names[],
|
|||
|
const size_t lens[], size_t argc);
|
|||
|
bool hmget(const string& req);
|
|||
|
|
|||
|
/**
|
|||
|
* <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><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ
|
|||
|
* @param i {size_t} <EFBFBD>±꣨<EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
* @param len {size_t*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><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>
|
|||
|
* @return {const char*} <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><EFBFBD>ϵİ<EFBFBD>ȫ<EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><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><EFBFBD>ý<EFBFBD>β<EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
const char* hmget_result(size_t i, size_t* len = NULL) const;
|
|||
|
|
|||
|
/////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
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 hset(const string& req);
|
|||
|
|
|||
|
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);
|
|||
|
int hsetnx(const string& req);
|
|||
|
|
|||
|
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);
|
|||
|
int hdel(const string& req);
|
|||
|
|
|||
|
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);
|
|||
|
|
|||
|
/////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
private:
|
|||
|
redis_client& conn_;
|
|||
|
const redis_result* result_;
|
|||
|
};
|
|||
|
|
|||
|
} // namespace acl
|