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_sockets. -
If
boost::redis::config::use_sslis `true`, performs the TLS handshake. -
Executes the setup request, as defined by the passed
configobject. By default, this is a `HELLO` command, but it can contain any other arbitrary commands. See theconfig::setupdocs for more info. -
Starts a health‐check operation where `PING` commands are sent at intervals specified by
config::health_check_intervalwhen the connection is idle. See the documentation ofconfig::health_check_intervalfor more info. -
Starts read and write operations. Requests issued using
async_execbefore `async_run` is 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 set boost::redis::config::reconnect_wait_interval to zero.
The completion token must have the following signature
void f(system::error_code);
Per‐operation cancellation
This operation supports the following cancellation types:
-
`asio::cancellation_type_t::terminal`.
-
`asio::cancellation_type_t::partial`.
In both cases, cancellation is equivalent to calling basic_connection::cancel passing operation::run as argument.
After the operation completes, the token's associated cancellation slot may still have a cancellation handler associated to this connection. You should make sure to not invoke it after the connection has been destroyed. This is consistent with what other Asio I/O objects do.
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