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

84 lines
2.0 KiB
C++
Raw Normal View History

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include "acl_cpp/redis/redis_command.hpp"
namespace acl
{
class redis_client;
2015-01-26 19:58:02 +08:00
/**
* redis Connection <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
* AUTH<EFBFBD><EFBFBD>ECHO<EFBFBD><EFBFBD>PING<EFBFBD><EFBFBD>QUIT<EFBFBD><EFBFBD>SELECT
2015-03-29 19:27:41 +08:00
* redis connection command clss, including as below:
* AUTH, ECHO, PING, QUIT, SELECT
2015-01-26 19:58:02 +08:00
*/
class ACL_CPP_API redis_connection : virtual public redis_command
{
public:
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command()
*/
redis_connection(void);
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command(redis_client*)
*/
redis_connection(redis_client* conn);
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command(redis_client_cluster*<EFBFBD><EFBFBD> size_t)
2015-03-29 19:27:41 +08:00
*/
redis_connection(redis_client_cluster* cluster, size_t max_conns = 0);
2015-03-29 19:27:41 +08:00
virtual ~redis_connection(void);
/////////////////////////////////////////////////////////////////////
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis-server ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤
2015-03-29 19:27:41 +08:00
* AUTH command to login the redis server.
2015-01-26 19:58:02 +08:00
* @param passwd {const char*} <EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-03-29 19:27:41 +08:00
* the password in redis-server configure
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>֤ʧ<EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
2015-03-29 19:27:41 +08:00
* return true if success, or false because auth failed or error.
2015-01-26 19:58:02 +08:00
*/
bool auth(const char* passwd);
2015-01-26 19:58:02 +08:00
/**
* ѡ<EFBFBD><EFBFBD> redis-server <EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD> ID
2015-03-29 19:27:41 +08:00
* SELECT command to select the DB id in redis-server
2015-01-26 19:58:02 +08:00
* @param dbnum {int} redis <EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD> ID
2015-03-29 19:27:41 +08:00
* the DB id
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
2015-03-29 19:27:41 +08:00
* return true if success, or false for failed.
2015-01-26 19:58:02 +08:00
*/
bool select(int dbnum);
2015-01-26 19:58:02 +08:00
/**
* ̽<EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-03-29 19:27:41 +08:00
* PING command for testing if the connection is OK
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-03-29 19:27:41 +08:00
* return true if success
2015-01-26 19:58:02 +08:00
*/
bool ping();
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis-server <EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
2015-03-29 19:27:41 +08:00
* ECHO command, request redis-server to echo something.
2015-01-26 19:58:02 +08:00
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
2015-03-29 19:27:41 +08:00
* return true if success
2015-01-26 19:58:02 +08:00
*/
bool echo(const char* s);
2015-01-26 19:58:02 +08:00
/**
* <EFBFBD>ر<EFBFBD> redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-03-29 19:27:41 +08:00
* QUIT command to close the redis connection
2015-01-26 19:58:02 +08:00
* @return {bool}
2015-03-29 19:27:41 +08:00
* return true if success
2015-01-26 19:58:02 +08:00
*/
bool quit();
};
} // namespace acl