Reference
boost::redis::basic_connection::async_run
Starts the underlying connection operations.
Synopsis
Declared in <boost/redis/connection.hpp>
template<class CompletionToken = asio::default_completion_token_t<executor_type>>
auto
async_run(
config const& cfg,
CompletionToken&& token = {});
Description
This function establishes a connection to the Redis server and keeps it healthy by performing the following operations:
-
For TCP connections, resolves the server hostname passed in
boost::redis::config::addr. -
Establishes a physical connection to the server. For TCP connections, connects to one of the endpoints obtained during name resolution. For UNIX domain socket connections, it connects to
boost::redis::config::unix_socket. -
If
boost::redis::config::use_sslistrue, performs the TLS handshake. -
Sends a
HELLOcommand where each of its parameters are read fromcfg. -
Starts a health‐check operation where ping commands are sent at intervals specified by
boost::redis::config::health_check_interval. The message passed toPINGwill beboost::redis::config::health_check_id. Passing an interval with a zero value 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. -
Starts read and write operations. Requests issued using
async_execbeforeasync_runis called will be written to the server immediately.
When a connection is lost for any reason, a new one is established automatically. To disable reconnection call boost::redis::connection::cancel(operation::reconnection) or set boost::redis::config::reconnect_wait_interval to zero.
The completion token must have the following signature
void f(system::error_code);
For example on how to call this function refer to cpp20_intro.cpp or any other example.
Parameters
Name |
Description |
cfg |
Configuration parameters. |
token |
Completion token. |
Created with MrDocs