Reference

boost::redis::basic_connection::async_run

Starts the underlying connection operations.

Synopsis

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_ssl is true, performs the TLS handshake.

  • Sends a HELLO command where each of its parameters are read from cfg.

  • Starts a health‐check operation where ping commands are sent at intervals specified by boost::redis::config::health_check_interval. The message passed to PING will be boost::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_exec before 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 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