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

88 lines
2.2 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
#include "redis_command.hpp"
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
namespace acl
{
class redis_client;
2015-01-26 19:58:02 +08:00
/**
* redis Connection
* AUTHECHOPINGQUITSELECT
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* 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
/**
* redis-server
2015-03-29 19:27:41 +08:00
* AUTH command to login the redis server.
* @param passwd {const char*} redis
2015-03-29 19:27:41 +08:00
* the password in redis-server configure
* @return {bool} false
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
/**
* redis-server ID
2015-03-29 19:27:41 +08:00
* SELECT command to select the DB id in redis-server
* @param dbnum {int} redis ID
2015-03-29 19:27:41 +08:00
* the DB id
* @return {bool}
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
/**
* redis
2015-03-29 19:27:41 +08:00
* PING command for testing if the connection is OK
* @return {bool}
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
/**
* redis-server
2015-03-29 19:27:41 +08:00
* ECHO command, request redis-server to echo something.
* @return {bool}
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
/**
* redis
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
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)