boost_redis 1.4.2
A redis client library
|
A SSL connection to the Redis server. More...
#include <include/boost/redis/connection.hpp>
Classes | |
struct | rebind_executor |
Rebinds the socket type to another executor. More... | |
Public Types | |
using | executor_type = Executor |
Executor type. | |
Public Member Functions | |
basic_connection (asio::io_context &ioc, asio::ssl::context::method method=asio::ssl::context::tls_client, std::size_t max_read_size=(std::numeric_limits< std::size_t >::max)()) | |
Contructs from a context. | |
basic_connection (executor_type ex, asio::ssl::context::method method=asio::ssl::context::tls_client, std::size_t max_read_size=(std::numeric_limits< std::size_t >::max)()) | |
Contructs from an executor. | |
template<class Response = ignore_t, class CompletionToken = asio::default_completion_token_t<executor_type>> | |
auto | async_exec (request const &req, Response &resp=ignore, CompletionToken &&token=CompletionToken{}) |
Executes commands on the Redis server asynchronously. More... | |
template<class Response = ignore_t, class CompletionToken = asio::default_completion_token_t<executor_type>> | |
auto | async_receive (Response &response, CompletionToken token=CompletionToken{}) |
Receives server side pushes asynchronously. More... | |
template<class Logger = logger, class CompletionToken = asio::default_completion_token_t<executor_type>> | |
auto | async_run (config const &cfg={}, Logger l=Logger{}, CompletionToken token=CompletionToken{}) |
Starts underlying connection operations. More... | |
void | cancel (operation op=operation::all) |
Cancel operations. More... | |
executor_type | get_executor () noexcept |
Returns the underlying executor. | |
auto const & | get_ssl_context () const noexcept |
Returns the ssl context. | |
auto & | get_ssl_context () noexcept |
Returns the ssl context. | |
auto const & | next_layer () const noexcept |
Returns a const reference to the next layer. | |
auto & | next_layer () noexcept |
Returns a reference to the next layer. | |
void | reset_stream () |
Resets the underlying stream. | |
bool | will_reconnect () const noexcept |
Returns true if the connection was canceled. | |
A SSL connection to the Redis server.
This class keeps a healthy connection to the Redis instance where commands can be sent at any time. For more details, please see the documentation of each individual function.
Socket | The socket type e.g. asio::ip::tcp::socket. |
Definition at line 72 of file connection.hpp.
struct boost::redis::basic_connection::rebind_executor |
Rebinds the socket type to another executor.
Definition at line 83 of file connection.hpp.
Class Members | ||
---|---|---|
typedef basic_connection< Executor1 > | other | The connection type when rebound to the specified executor. |
|
inline |
Executes commands on the Redis server asynchronously.
This function sends a request to the Redis server and waits for the responses to each individual command in the request. If the request contains only commands that don't expect a response, the completion occurs after it has been written to the underlying stream. Multiple concurrent calls to this function will be automatically queued by the implementation.
req | Request. |
resp | Response. |
token | Completion token. |
For an example see cpp20_echo_server.cpp. The completion token must have the following signature
Where the second parameter is the size of the response received in bytes.
Definition at line 227 of file connection.hpp.
|
inline |
Receives server side pushes asynchronously.
When pushes arrive and there is no async_receive
operation in progress, pushed data, requests, and responses will be paused until async_receive
is called again. Apps will usually want to call async_receive
in a loop.
To cancel an ongoing receive operation apps should call connection::cancel(operation::receive)
.
response | Response object. |
token | Completion token. |
For an example see cpp20_subscriber.cpp. The completion token must have the following signature
Where the second parameter is the size of the push received in bytes.
Definition at line 192 of file connection.hpp.
|
inline |
Starts underlying connection operations.
This member function provides the following functionality
boost::redis::config::addr
.cfg
.boost::redis::config::health_check_interval
. The message passed to PING
will be boost::redis::config::health_check_id
. Passing a timeout with value zero will disable health-checks. If the Redis server does not respond to a health-check within two times the value specified here, it will be considered unresponsive and the connection will be closed and a new connection will be stablished.async_exec
that happened prior to this call.When a connection is lost for any reason, a new one is stablished automatically. To disable reconnection call boost::redis::connection::cancel(operation::reconnection)
.
cfg | Configuration paramters. |
l | Logger object. The interface expected is specified in the class boost::redis::logger . |
token | Completion token. |
The completion token must have the following signature
For example on how to call this function refer to cpp20_intro.cpp or any other example.
Definition at line 149 of file connection.hpp.
|
inline |
Cancel operations.
operation::exec
: Cancels operations started with async_exec
. Affects only requests that haven't been written yet. async_run
operation. async_receive
. op | The operation to be cancelled. |
Definition at line 247 of file connection.hpp.