2015-01-19 00:03:30 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
|
|
|
|
#include "redis_command.hpp"
|
2015-01-19 00:03:30 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2015-01-19 00:03:30 +08:00
|
|
|
|
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
|
|
|
|
*/
|
2015-03-27 17:05:12 +08:00
|
|
|
|
class ACL_CPP_API redis_connection : virtual public redis_command
|
2015-01-19 00:03:30 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-03-29 19:27:41 +08:00
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command()
|
|
|
|
|
*/
|
2016-01-17 13:35:12 +08:00
|
|
|
|
redis_connection(void);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command(redis_client*)
|
|
|
|
|
*/
|
2015-03-27 17:05:12 +08:00
|
|
|
|
redis_connection(redis_client* conn);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-04-02 22:19:57 +08:00
|
|
|
|
* see redis_command::redis_command(redis_client_cluster*<EFBFBD><EFBFBD> size_t)
|
2015-03-29 19:27:41 +08:00
|
|
|
|
*/
|
2016-01-17 13:35:12 +08:00
|
|
|
|
redis_connection(redis_client_cluster* cluster, size_t max_conns = 0);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
2016-01-17 13:35:12 +08:00
|
|
|
|
virtual ~redis_connection(void);
|
2015-01-19 00:03:30 +08:00
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
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
|
|
|
|
*/
|
2015-01-19 00:03:30 +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
|
|
|
|
*/
|
2015-01-19 00:03:30 +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
|
|
|
|
*/
|
2015-01-19 00:03:30 +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
|
|
|
|
*/
|
2015-01-19 00:03:30 +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
|
|
|
|
*/
|
2015-01-19 00:03:30 +08:00
|
|
|
|
bool quit();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
|