2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include <vector>
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stream/socket_stream.hpp"
|
|
|
|
|
#include "../stdlib/string.hpp"
|
|
|
|
|
#include "../connpool/connect_client.hpp"
|
2014-11-19 00:25:21 +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-14 23:35:23 +08:00
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class dbuf_pool;
|
|
|
|
|
class redis_result;
|
2015-01-26 19:58:02 +08:00
|
|
|
|
class redis_request;
|
2019-12-18 11:40:41 +08:00
|
|
|
|
class sslbase_conf;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-03-29 19:27:41 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* redis <EFBFBD>ͻ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>࣬ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ཫ<EFBFBD><EFBFBD>֯<EFBFBD>õ<EFBFBD> redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><EFBFBD><EFBFBD> connect_client <EFBFBD>࣬<EFBFBD><EFBFBD>Ҫ
|
|
|
|
|
* Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳع<EFBFBD><EFBFBD>ܡ<EFBFBD>
|
2015-03-29 19:27:41 +08:00
|
|
|
|
* redis client network IO class. The redis request is sent to server
|
|
|
|
|
* and the server's respond is handled in this class. The class inherits
|
|
|
|
|
* connect_client, which can use the connection pool function.
|
|
|
|
|
*/
|
2015-01-14 23:35:23 +08:00
|
|
|
|
class ACL_CPP_API redis_client : public connect_client
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-04-08 23:17:16 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* constructor
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param addr {const char*} redis-server <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* the redis-server listening addr
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param conn_timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis-server <EFBFBD>ij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* the timeout in seconds to connect the redis-server
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param rw_timeout {int} <EFBFBD><EFBFBD> redis-server <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD> IO <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* the network IO timeout in seconds with the redis-server
|
|
|
|
|
*/
|
2015-01-14 23:35:23 +08:00
|
|
|
|
redis_client(const char* addr, int conn_timeout = 60,
|
|
|
|
|
int rw_timeout = 30, bool retry = true);
|
2016-01-17 13:35:12 +08:00
|
|
|
|
~redis_client(void);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-06-08 14:06:22 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> SSL ͨ<EFBFBD>ŷ<EFBFBD>ʽ<EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>þ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>ȱʡֵΪ NULL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SSL <EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD> SSL ͨ<EFBFBD>ŷ<EFBFBD>ʽ
|
2019-06-08 14:06:22 +08:00
|
|
|
|
* set SSL communication with Redis-server if ssl_conf not NULL
|
2019-12-18 11:40:41 +08:00
|
|
|
|
* @param ssl_conf {sslbase_conf*}
|
2019-06-08 14:06:22 +08:00
|
|
|
|
*/
|
2019-12-18 11:40:41 +08:00
|
|
|
|
void set_ssl_conf(sslbase_conf* ssl_conf);
|
2019-06-08 14:06:22 +08:00
|
|
|
|
|
2015-10-20 21:07:23 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-10-20 21:07:23 +08:00
|
|
|
|
* @param pass {const char*}
|
|
|
|
|
*/
|
2015-11-13 16:26:30 +08:00
|
|
|
|
void set_password(const char* pass);
|
2015-10-20 21:07:23 +08:00
|
|
|
|
|
2018-10-20 22:20:57 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD> db<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> db ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD>
|
|
|
|
|
* ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD> db<EFBFBD><EFBFBD>ע<EFBFBD>⣺<EFBFBD>ù<EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԷǼ<EFBFBD>Ⱥģʽ
|
2018-10-20 22:20:57 +08:00
|
|
|
|
* if db > 0 in no cluster mode, select the db when the connection
|
|
|
|
|
* is created.
|
|
|
|
|
* @param dbnum {int}
|
|
|
|
|
*/
|
|
|
|
|
void set_db(int dbnum);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> db
|
2018-10-20 22:20:57 +08:00
|
|
|
|
* get db for the connection
|
|
|
|
|
* @return {int}
|
|
|
|
|
*/
|
|
|
|
|
int get_db(void) const
|
|
|
|
|
{
|
|
|
|
|
return dbnum_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-12 20:11:15 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ӵķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis_client <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
|
2016-04-12 20:11:15 +08:00
|
|
|
|
* @return {const char*}
|
|
|
|
|
*/
|
|
|
|
|
const char* get_addr(void) const
|
|
|
|
|
{
|
|
|
|
|
return addr_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-15 13:39:26 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> socket <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> DEBUG ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD>
|
2016-12-15 13:39:26 +08:00
|
|
|
|
* @param on {bool}
|
|
|
|
|
*/
|
|
|
|
|
void set_check_addr(bool on);
|
|
|
|
|
|
2015-04-08 23:17:16 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>жϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD>ر<EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* check if the connection has been finish
|
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
2018-10-20 22:20:57 +08:00
|
|
|
|
bool eof(void) const;
|
2015-04-08 23:17:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* close the connection to the redis-server
|
|
|
|
|
*/
|
2018-10-20 22:20:57 +08:00
|
|
|
|
void close(void);
|
2015-01-14 23:35:23 +08:00
|
|
|
|
|
2015-04-08 23:17:16 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* get acl::socket_stream from the connection
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {acl::socket_stream*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD> NULL
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* NULL will be returned if the connectioin has been closed
|
|
|
|
|
*/
|
2018-10-20 22:20:57 +08:00
|
|
|
|
socket_stream* get_stream(void);
|
2015-01-26 19:58:02 +08:00
|
|
|
|
|
2015-04-08 23:17:16 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ϳ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* just for request package, setting flag for sending data with
|
|
|
|
|
* multi data chunks; this is useful when the request data is large
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param on {bool} <EFBFBD><EFBFBD>Ϊ true ʱ<EFBFBD>Ὣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺϳ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* if true the request data will not be combined one package
|
|
|
|
|
*/
|
2015-02-13 22:52:43 +08:00
|
|
|
|
void set_slice_request(bool on);
|
2015-04-08 23:17:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD> redis-server <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷֲ<EFBFBD><EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ飬
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԵĴ<EFBFBD><EFBFBD>ڴ<EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* just for response package, settint flag for receiving data
|
|
|
|
|
* if split the large response data into multi little chunks
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param on {bool} <EFBFBD><EFBFBD>Ϊ true ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* if true the response data will be splitted into multi little
|
|
|
|
|
* data, which is useful for large reponse data for avoiding
|
|
|
|
|
* malloc large continuously memory from system.
|
|
|
|
|
*/
|
2015-02-13 22:52:43 +08:00
|
|
|
|
void set_slice_respond(bool on);
|
2015-01-14 23:35:23 +08:00
|
|
|
|
|
2015-04-08 23:17:16 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ڷǷ<EFBFBD>Ƭ<EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis-server <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ͬʱ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* send request to redis-server, and read/anlyse response from server,
|
|
|
|
|
* this function will be used for no-slice request mode.
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param pool {dbuf_pool*} <EFBFBD>ڴ<EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* memory pool manager
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param req {const string&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* the request package
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param nchildren {size_t} <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* the data object number in the server's response data
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {const redis_result*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD>ͷţ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pool <EFBFBD>ڴ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>
|
|
|
|
|
* <EFBFBD>ͷ<EFBFBD> pool ʱ<EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һͬ<EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* the result object from server's response, NULL will be returned
|
|
|
|
|
* when some error happens; the result object needn't be freed
|
|
|
|
|
* manually, which was created in the pool object, and will be freed
|
|
|
|
|
* when the pool were freed.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2015-02-13 22:52:43 +08:00
|
|
|
|
const redis_result* run(dbuf_pool* pool, const string& req,
|
2016-11-18 21:45:40 +08:00
|
|
|
|
size_t nchildren, int* rw_timeout = NULL);
|
2015-04-08 23:17:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD>Ƭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* just for sending proccess in slice request mode
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param req {const redis_request&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-08 23:17:16 +08:00
|
|
|
|
* request object
|
|
|
|
|
*/
|
2015-02-13 22:52:43 +08:00
|
|
|
|
const redis_result* run(dbuf_pool* pool, const redis_request& req,
|
2016-11-18 21:45:40 +08:00
|
|
|
|
size_t nchildren, int* rw_timeout = NULL);
|
2015-01-14 23:35:23 +08:00
|
|
|
|
|
|
|
|
|
protected:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF>
|
2018-10-20 22:20:57 +08:00
|
|
|
|
// @override
|
2019-06-08 14:06:22 +08:00
|
|
|
|
bool open(void);
|
2015-01-14 23:35:23 +08:00
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
private:
|
|
|
|
|
socket_stream conn_;
|
2018-10-20 22:20:57 +08:00
|
|
|
|
bool check_addr_;
|
|
|
|
|
char* addr_;
|
|
|
|
|
char* pass_;
|
|
|
|
|
bool retry_;
|
|
|
|
|
bool authing_;
|
|
|
|
|
string buf_;
|
|
|
|
|
bool slice_req_;
|
|
|
|
|
bool slice_res_;
|
|
|
|
|
int dbnum_;
|
2019-12-18 11:40:41 +08:00
|
|
|
|
sslbase_conf* ssl_conf_;
|
2015-01-21 23:39:02 +08:00
|
|
|
|
|
2015-02-13 22:52:43 +08:00
|
|
|
|
redis_result* get_redis_objects(dbuf_pool* pool, size_t nobjs);
|
|
|
|
|
redis_result* get_redis_object(dbuf_pool* pool);
|
|
|
|
|
redis_result* get_redis_error(dbuf_pool* pool);
|
|
|
|
|
redis_result* get_redis_status(dbuf_pool* pool);
|
|
|
|
|
redis_result* get_redis_integer(dbuf_pool* pool);
|
|
|
|
|
redis_result* get_redis_string(dbuf_pool* pool);
|
|
|
|
|
redis_result* get_redis_array(dbuf_pool* pool);
|
2015-01-26 19:58:02 +08:00
|
|
|
|
|
2015-02-13 22:52:43 +08:00
|
|
|
|
void put_data(dbuf_pool* pool, redis_result* rr,
|
|
|
|
|
const char* data, size_t len);
|
2016-12-15 13:39:26 +08:00
|
|
|
|
bool check_connection(socket_stream& conn);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // end 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)
|