2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
2015-01-14 23:35:23 +08:00
|
|
|
|
#include <vector>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include "acl_cpp/stdlib/string.hpp"
|
2015-01-20 00:10:17 +08:00
|
|
|
|
#include "acl_cpp/redis/redis_command.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
2015-01-14 23:35:23 +08:00
|
|
|
|
class redis_result;
|
|
|
|
|
|
|
|
|
|
// redis <20><><EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
REDIS_KEY_UNKNOWN,
|
|
|
|
|
REDIS_KEY_NONE,
|
|
|
|
|
REDIS_KEY_STRING, // string
|
|
|
|
|
REDIS_KEY_HASH, // hash
|
|
|
|
|
REDIS_KEY_LIST, // list
|
|
|
|
|
REDIS_KEY_SET, // set
|
|
|
|
|
REDIS_KEY_ZSET // sorted set
|
|
|
|
|
} redis_key_t;
|
|
|
|
|
|
2015-01-20 00:10:17 +08:00
|
|
|
|
class ACL_CPP_API redis_key : public redis_command
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-01-16 17:08:31 +08:00
|
|
|
|
redis_key(redis_client* conn = NULL);
|
2015-01-14 23:35:23 +08:00
|
|
|
|
~redis_key();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ɾ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> KEY
|
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY <EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|
|
|
|
* 0: δɾ<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD> KEY
|
|
|
|
|
* -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* >0: <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> KEY <EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int del(const char* first_key, ...) ACL_CPP_PRINTF(2, 3);
|
|
|
|
|
int del(const std::vector<string>& keys);
|
|
|
|
|
int del(const std::vector<char*>& keys);
|
|
|
|
|
int del(const std::vector<const char*>& keys);
|
|
|
|
|
int del(const std::vector<int>& keys);
|
|
|
|
|
int del(const char* keys[], size_t argc);
|
|
|
|
|
int del(const int keys[], size_t argc);
|
|
|
|
|
int del(const char* keys[], const size_t lens[], size_t argc);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>룩
|
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param n {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>룩
|
|
|
|
|
* @return {int} <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>
|
|
|
|
|
* 0<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>
|
|
|
|
|
* < 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int expire(const char* key, int n);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY <EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>룩
|
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>Ӧ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* > 0: <EFBFBD><EFBFBD> key ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>룩
|
|
|
|
|
* 0<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>
|
|
|
|
|
* < 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int ttl(const char* key);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ж<EFBFBD> KEY <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param key {const char*} KEY ֵ
|
|
|
|
|
* @return {bool} <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>
|
|
|
|
|
*/
|
|
|
|
|
bool exists(const char* key);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY <EFBFBD>Ĵ洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @para key {const char*} KEY ֵ
|
|
|
|
|
* @return {redis_key_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> KEY <EFBFBD>Ĵ洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
redis_key_t type(const char* key);
|
|
|
|
|
|
2015-01-19 00:03:30 +08:00
|
|
|
|
bool migrate(const char* key, const char* addr, unsigned dest_db,
|
|
|
|
|
unsigned timeout, const char* option = NULL);
|
|
|
|
|
|
|
|
|
|
int move(const char* key, unsigned dest_db);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|