4 #ifndef __STDC_FORMAT_MACROS
5 #define __STDC_FORMAT_MACROS
30 return code_ ==
"not_found";
47 Status(
const std::string &
code){
50 Status(
const std::vector<std::string> *resp){
51 if(resp && resp->size() > 0){
66 static Client* connect(
const char *ip,
int port);
74 virtual const std::vector<std::string>* request(
const std::vector<std::string> &req) = 0;
75 virtual const std::vector<std::string>* request(
const std::string &cmd) = 0;
76 virtual const std::vector<std::string>* request(
const std::string &cmd,
const std::string &s2) = 0;
77 virtual const std::vector<std::string>* request(
const std::string &cmd,
const std::string &s2,
const std::string &s3) = 0;
78 virtual const std::vector<std::string>* request(
const std::string &cmd,
const std::string &s2,
const std::string &s3,
const std::string &s4) = 0;
79 virtual const std::vector<std::string>* request(
const std::string &cmd,
const std::string &s2,
const std::string &s3,
const std::string &s4,
const std::string &s5) = 0;
80 virtual const std::vector<std::string>* request(
const std::string &cmd,
const std::string &s2,
const std::string &s3,
const std::string &s4,
const std::string &s5,
const std::string &s6) = 0;
85 virtual Status get(
const std::string &key, std::string *val) = 0;
86 virtual Status set(
const std::string &key,
const std::string &val) = 0;
90 virtual Status setx(
const std::string &key,
const std::string &val,
int ttl) = 0;
91 virtual Status del(
const std::string &key) = 0;
92 virtual Status incr(
const std::string &key, int64_t incrby, int64_t *ret) = 0;
97 virtual Status keys(
const std::string &key_start,
const std::string &key_end,
98 uint64_t limit, std::vector<std::string> *ret) = 0;
103 virtual Status scan(
const std::string &key_start,
const std::string &key_end,
104 uint64_t limit, std::vector<std::string> *ret) = 0;
109 virtual Status rscan(
const std::string &key_start,
const std::string &key_end,
110 uint64_t limit, std::vector<std::string> *ret) = 0;
116 virtual Status hget(
const std::string &name,
const std::string &key, std::string *val) = 0;
117 virtual Status hset(
const std::string &name,
const std::string &key,
const std::string &val) = 0;
118 virtual Status hdel(
const std::string &name,
const std::string &key) = 0;
119 virtual Status hincr(
const std::string &name,
const std::string &key, int64_t incrby, int64_t *ret) = 0;
120 virtual Status hsize(
const std::string &name, int64_t *ret) = 0;
124 virtual Status hclear(
const std::string &name, int64_t *ret) = 0;
130 const std::string &key_start,
const std::string &key_end,
131 uint64_t limit, std::vector<std::string> *ret) = 0;
137 const std::string &key_start,
const std::string &key_end,
138 uint64_t limit, std::vector<std::string> *ret) = 0;
144 const std::string &key_start,
const std::string &key_end,
145 uint64_t limit, std::vector<std::string> *ret) = 0;
151 virtual Status zget(
const std::string &name,
const std::string &key, int64_t *ret) = 0;
152 virtual Status zset(
const std::string &name,
const std::string &key, int64_t score) = 0;
153 virtual Status zdel(
const std::string &name,
const std::string &key) = 0;
154 virtual Status zincr(
const std::string &name,
const std::string &key, int64_t incrby, int64_t *ret) = 0;
155 virtual Status zsize(
const std::string &name, int64_t *ret) = 0;
159 virtual Status zclear(
const std::string &name, int64_t *ret) = 0;
163 virtual Status zrank(
const std::string &name,
const std::string &key, int64_t *ret) = 0;
167 virtual Status zrrank(
const std::string &name,
const std::string &key, int64_t *ret) = 0;
172 uint64_t offset, uint64_t limit,
173 std::vector<std::string> *ret) = 0;
178 uint64_t offset, uint64_t limit,
179 std::vector<std::string> *ret) = 0;
184 virtual Status zkeys(
const std::string &name,
const std::string &key_start,
185 int64_t *score_start, int64_t *score_end,
186 uint64_t limit, std::vector<std::string> *ret) = 0;
191 virtual Status zscan(
const std::string &name,
const std::string &key_start,
192 int64_t *score_start, int64_t *score_end,
193 uint64_t limit, std::vector<std::string> *ret) = 0;
198 virtual Status zrscan(
const std::string &name,
const std::string &key_start,
199 int64_t *score_start, int64_t *score_end,
200 uint64_t limit, std::vector<std::string> *ret) = 0;
206 void operator=(
const Client&);
virtual Status setx(const std::string &key, const std::string &val, int ttl)=0
Set the value of the key, with a time to live.
virtual Status zrange(const std::string &name, uint64_t offset, uint64_t limit, std::vector< std::string > *ret)=0
Important! This method is SLOW for large offset!
virtual Status hclear(const std::string &name, int64_t *ret)=0
Delete all of the keys in a hashmap, return the number of keys deleted.
bool error()
Returns true if error occurs during the request.
Definition: SSDB.h:36
virtual Status hscan(const std::string &name, const std::string &key_start, const std::string &key_end, uint64_t limit, std::vector< std::string > *ret)=0
Return key-value pairs.
virtual Status hrscan(const std::string &name, const std::string &key_start, const std::string &key_end, uint64_t limit, std::vector< std::string > *ret)=0
Return key-value pairs.
bool not_found()
Returns true if the requested key is not found.
Definition: SSDB.h:29
virtual Status zscan(const std::string &name, const std::string &key_start, int64_t *score_start, int64_t *score_end, uint64_t limit, std::vector< std::string > *ret)=0
Return key-score pairs.
virtual Status hkeys(const std::string &name, const std::string &key_start, const std::string &key_end, uint64_t limit, std::vector< std::string > *ret)=0
virtual Status rscan(const std::string &key_start, const std::string &key_end, uint64_t limit, std::vector< std::string > *ret)=0
Return key-value pairs.
bool ok()
Returns true if the request succeeded.
Definition: SSDB.h:22
virtual Status scan(const std::string &key_start, const std::string &key_end, uint64_t limit, std::vector< std::string > *ret)=0
Return key-value pairs.
virtual Status zrrank(const std::string &name, const std::string &key, int64_t *ret)=0
Important! This method may be extremly SLOW!
virtual Status zrscan(const std::string &name, const std::string &key_start, int64_t *score_start, int64_t *score_end, uint64_t limit, std::vector< std::string > *ret)=0
Return key-score pairs.
virtual Status zrank(const std::string &name, const std::string &key, int64_t *ret)=0
Important! This method may be extremly SLOW!
std::string code()
The response code.
Definition: SSDB.h:42
virtual Status keys(const std::string &key_start, const std::string &key_end, uint64_t limit, std::vector< std::string > *ret)=0
Client requests' return status.
Definition: SSDB.h:17
virtual Status zrrange(const std::string &name, uint64_t offset, uint64_t limit, std::vector< std::string > *ret)=0
Important! This method is SLOW for large offset!
virtual Status zkeys(const std::string &name, const std::string &key_start, int64_t *score_start, int64_t *score_end, uint64_t limit, std::vector< std::string > *ret)=0
The SSDB client used to connect to SSDB server.
Definition: SSDB.h:64
virtual Status zclear(const std::string &name, int64_t *ret)=0
Delete all of the keys in a zset, return the number of keys deleted.