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

87 lines
2.2 KiB
C++
Raw Normal View History

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"
#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;
class ACL_CPP_API redis_key : public redis_command
2014-11-19 00:25:21 +08:00
{
public:
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);
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