![]() |
cpp_redis
4.0.0
cpp_redis is a C++11 Asynchronous Multi-Platform Lightweight Redis Client, with support for synchronous operations and pipelining.
|
#include <redis_connection.hpp>
Public Types | |
| typedef std::function< void(redis_connection &)> | disconnection_handler_t |
| typedef std::function< void(redis_connection &, reply &)> | reply_callback_t |
Public Member Functions | |
| redis_connection (void) | |
| ctor | |
| redis_connection (const std::shared_ptr< tcp_client_iface > &tcp_client) | |
| ~redis_connection (void) | |
| dtor | |
| redis_connection (const redis_connection &)=delete | |
| copy ctor | |
| redis_connection & | operator= (const redis_connection &)=delete |
| assignment operator | |
| void | connect (const std::string &host="127.0.0.1", std::size_t port=6379, const disconnection_handler_t &disconnection_handler=nullptr, const reply_callback_t &reply_callback=nullptr, std::uint32_t timeout_msecs=0) |
| void | disconnect (bool wait_for_removal=false) |
| bool | is_connected (void) const |
| redis_connection & | send (const std::vector< std::string > &redis_cmd) |
| redis_connection & | commit (void) |
tcp connection wrapper handling redis protocol
| typedef std::function<void(redis_connection&)> cpp_redis::network::redis_connection::disconnection_handler_t |
disconnection handler takes as parameter the instance of the redis_connection
| typedef std::function<void(redis_connection&, reply&)> cpp_redis::network::redis_connection::reply_callback_t |
reply handler takes as parameter the instance of the redis_connection and the built reply
|
explicit |
ctor allowing to specify custom tcp client (default ctor uses the default tacopie tcp client)
| tcp_client | tcp client to be used for network communications |
| redis_connection& cpp_redis::network::redis_connection::commit | ( | void | ) |
commit pipelined transaction that is, send to the network all commands pipelined by calling send()
| void cpp_redis::network::redis_connection::connect | ( | const std::string & | host = "127.0.0.1", |
| std::size_t | port = 6379, |
||
| const disconnection_handler_t & | disconnection_handler = nullptr, |
||
| const reply_callback_t & | reply_callback = nullptr, |
||
| std::uint32_t | timeout_msecs = 0 |
||
| ) |
connect to the given host and port, and set both disconnection and reply callbacks
| host | host to be connected to |
| port | port to be connected to |
| disconnection_handler | handler to be called in case of disconnection |
| reply_callback | handler to be called once a reply is ready |
| timeout_msecs | max time to connect (in ms) |
| void cpp_redis::network::redis_connection::disconnect | ( | bool | wait_for_removal = false | ) |
disconnect from redis server
| wait_for_removal | when sets to true, disconnect blocks until the underlying TCP client has been effectively removed from the io_service and that all the underlying callbacks have completed. |
| bool cpp_redis::network::redis_connection::is_connected | ( | void | ) | const |
| redis_connection& cpp_redis::network::redis_connection::send | ( | const std::vector< std::string > & | redis_cmd | ) |
send the given command the command is actually pipelined and only buffered, so nothing is sent to the network please call commit() to flush the buffer
| redis_cmd | command to be sent |
1.8.13