Reference

boost::redis::basic_connection::async_exec

Executes commands on the Redis server asynchronously.

Synopsis

template<class CompletionToken = asio::default_completion_token_t<executor_type>>
auto
async_exec(
    request const& req,
    any_adapter adapter,
    CompletionToken&& token = {});

Description

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.

For an example see cpp20_echo_server.cpp.

The completion token must have the following signature:

void f(system::error_code, std::size_t);

Where the second parameter is the size of the response received in bytes.

Per‐operation cancellation

This operation supports per‐operation cancellation. The following cancellation types are supported:

  • asio::cancellation_type_t::terminal. Always supported. May cause the current async_run operation to be cancelled.

  • asio::cancellation_type_t::partial and asio::cancellation_type_t::total. Supported only if the request hasn't been written to the network yet.

Object lifetimes

Both req and any response object referenced by adapter should be kept alive until the operation completes. No copies of the request object are made.

Parameters

Name

Description

req

The request to be executed.

adapter

An adapter object referencing a response to place data into.

token

Completion token.

Created with MrDocs