Boost.Redis 1.4.2
A redis client library
Loading...
Searching...
No Matches
Reference

Classes

struct  boost::redis::address
 Address of a Redis server. More...
 
class  boost::redis::basic_connection< Executor >
 A SSL connection to the Redis server. More...
 
struct  boost::redis::resp3::basic_node< String >
 A node in the response tree. More...
 
struct  boost::redis::config
 Configure parameters used by the connection classes. More...
 
class  boost::redis::connection
 A basic_connection that type erases the executor. More...
 
class  boost::redis::detail::connection_base< Executor >
 Base class for high level Redis asynchronous connections. More...
 
struct  boost::redis::adapter::error
 Stores any resp3 error. More...
 
struct  boost::redis::adapter::ignore
 An adapter that ignores responses. More...
 
class  boost::redis::logger
 Logger class. More...
 
class  boost::redis::request
 Creates Redis requests. More...
 
struct  boost::redis::usage
 Connection usage information. More...
 

Typedefs

using boost::redis::generic_response = adapter::result< std::vector< resp3::node > >
 A generic response to a request. More...
 
using boost::redis::ignore_t = std::decay_t< decltype(std::ignore)>
 Type used to ignore responses. More...
 
using boost::redis::resp3::node = basic_node< std::string >
 A node in the response tree.
 
template<class... Ts>
using boost::redis::response = std::tuple< adapter::result< Ts >... >
 Response with compile-time size.
 
template<class Value >
using boost::redis::adapter::result = system::result< Value, error >
 Stores response to individual Redis commands.
 

Enumerations

enum class  boost::redis::error
 Generic errors. More...
 
enum class  boost::redis::logger::level
 Syslog-like log levels. More...
 
enum class  boost::redis::operation
 Connection operations that can be cancelled. More...
 
enum class  boost::redis::resp3::type
 RESP3 data types. More...
 

Functions

 boost::redis::logger::logger (level l=level::disabled)
 Constructor. More...
 
void boost::redis::logger::on_connect (system::error_code const &ec, asio::ip::tcp::endpoint const &ep)
 Called when the connect operation completes. More...
 
void boost::redis::logger::on_connection_lost (system::error_code const &ec)
 Called when the connection is lost. More...
 
void boost::redis::logger::on_hello (system::error_code const &ec, generic_response const &resp)
 Called when the HELLO request completes. More...
 
void boost::redis::logger::on_read (system::error_code const &ec, std::size_t n)
 Called when the read operation completes. More...
 
void boost::redis::logger::on_resolve (system::error_code const &ec, asio::ip::tcp::resolver::results_type const &res)
 Called when the resolve operation completes. More...
 
void boost::redis::logger::on_run (system::error_code const &reader_ec, system::error_code const &writer_ec)
 Called when the run operation completes. More...
 
void boost::redis::logger::on_runner (system::error_code const &run_all_ec, system::error_code const &health_check_ec, system::error_code const &hello_ec)
 Called when the runner operation completes. More...
 
void boost::redis::logger::on_ssl_handshake (system::error_code const &ec)
 Called when the ssl handshake operation completes. More...
 
void boost::redis::logger::on_write (system::error_code const &ec, std::string const &payload)
 Called when the write operation completes. More...
 
auto boost::redis::resp3::operator<< (std::ostream &os, type t) -> std::ostream &
 Writes the type to the output stream. More...
 
void boost::redis::logger::set_prefix (std::string_view prefix)
 Sets a prefix to every log message. More...
 
auto boost::redis::resp3::to_string (type t) noexcept -> char const *
 Converts the data type to a string. More...
 

Variables

ignore_t boost::redis::ignore
 Global ignore object. More...
 

Detailed Description

This page contains the documentation of the Aedis high-level API.


Class Documentation

◆ boost::redis::address

struct boost::redis::address

Address of a Redis server.

Definition at line 20 of file config.hpp.

Class Members
string host = "127.0.0.1" Redis host.
string port = "6379" Redis port.

◆ boost::redis::config

struct boost::redis::config

Configure parameters used by the connection classes.

Definition at line 30 of file config.hpp.

Class Members
address addr = address{"127.0.0.1", "6379"} Address of the Redis server.
string clientname = "Boost.Redis" Client name parameter of the HELLO command.
duration connect_timeout = std::chrono::seconds{10} Time the connect operation is allowed to last.
optional< int > database_index = 0 Database that will be passed to the SELECT command.
string health_check_id = "Boost.Redis" Message used by the health-checker in boost::redis::connection::async_run.
duration health_check_interval = std::chrono::seconds{2}

Health checks interval.

To disable health-checks pass zero as duration.

string log_prefix = "(Boost.Redis) " Logger prefix, see boost::redis::logger.
string password Password passed to the HELLO command. If left empty HELLO will be sent without authentication parameters.
duration reconnect_wait_interval = std::chrono::seconds{1} Time waited before trying a reconnection.

To disable reconnection pass zero as duration.

duration resolve_timeout = std::chrono::seconds{10} Time the resolve operation is allowed to last.
duration ssl_handshake_timeout = std::chrono::seconds{10} Time the SSL handshake operation is allowed to last.
bool use_ssl = false Uses SSL instead of a plain connection.
string username Username passed to the HELLO command. If left empty HELLO will be sent without authentication parameters.

◆ boost::redis::usage

struct boost::redis::usage

Connection usage information.

Note
: To simplify the implementation, the commands_sent and bytes_sent in the struct below are computed just before writing to the socket, which means on error they might not represent exaclty what has been received by the Redis server.

Definition at line 21 of file usage.hpp.

Class Members
size_t bytes_sent = 0 Number of bytes sent.
size_t commands_sent = 0 Number of commands sent.
size_t push_bytes_received = 0 Number of push-bytes received.
size_t pushes_received = 0 Number of pushes received.
size_t response_bytes_received = 0 Number of response-bytes received.
size_t responses_received = 0 Number of responses received.

Typedef Documentation

◆ generic_response

A generic response to a request.

This response type can store any type of RESP3 data structure. It contains the pre-order view of the response tree.

Definition at line 35 of file response.hpp.

◆ ignore_t

using boost::redis::ignore_t = typedef std::decay_t<decltype(std::ignore)>

Type used to ignore responses.

For example

std::tuple< adapter::result< Ts >... > response
Response with compile-time size.
Definition: response.hpp:25

will ignore the first and third responses. RESP3 errors won't be ignore but will cause async_exec to complete with an error.

Definition at line 31 of file ignore.hpp.

Enumeration Type Documentation

◆ error

enum class boost::redis::error
strong

Generic errors.

Enumerator
invalid_data_type 

Invalid RESP3 type.

not_a_number 

Can't parse the string as a number.

exceeeds_max_nested_depth 

The maximum depth of a nested response was exceeded.

unexpected_bool_value 

Got non boolean value.

empty_field 

Expected field value is empty.

expects_resp3_simple_type 

Expects a simple RESP3 type but got an aggregate.

expects_resp3_aggregate 

Expects aggregate.

expects_resp3_map 

Expects a map but got other aggregate.

expects_resp3_set 

Expects a set aggregate but got something else.

nested_aggregate_not_supported 

Nested response not supported.

resp3_simple_error 

Got RESP3 simple error.

resp3_blob_error 

Got RESP3 blob_error.

incompatible_size 

Aggregate container has incompatible size.

not_a_double 

Not a double.

resp3_null 

Got RESP3 null.

not_connected 

There is no stablished connection.

resolve_timeout 

Resolve timeout.

connect_timeout 

Connect timeout.

pong_timeout 

Connect timeout.

ssl_handshake_timeout 

SSL handshake timeout.

sync_receive_push_failed 

Can't receive push synchronously without blocking.

incompatible_node_depth 

Incompatible node depth.

Definition at line 17 of file error.hpp.

◆ level

enum class boost::redis::logger::level
strong

Syslog-like log levels.

Enumerator
disabled 

Disabled.

emerg 

Emergency.

alert 

Alert.

crit 

Critical.

err 

Error.

warning 

Warning.

notice 

Notice.

info 

Info.

debug 

Debug.

Definition at line 32 of file logger.hpp.

◆ operation

enum class boost::redis::operation
strong

Connection operations that can be cancelled.

The operations listed below can be passed to the boost::redis::connection::cancel member function.

Enumerator
resolve 

Resolve operation.

connect 

Connect operation.

ssl_handshake 

SSL handshake operation.

exec 

Refers to connection::async_exec operations.

run 

Refers to connection::async_run operations.

receive 

Refers to connection::async_receive operations.

reconnection 

Cancels reconnection.

health_check 

Health check operation.

all 

Refers to all operations.

Definition at line 18 of file operation.hpp.

◆ type

enum class boost::redis::resp3::type
strong

RESP3 data types.

The RESP3 specification can be found at https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md.

Enumerator
array 

Aggregate.

push 

Aaggregate.

set 

Aggregate.

map 

Aggregate.

attribute 

Aggregate.

simple_string 

Simple.

simple_error 

Simple.

number 

Simple.

doublean 

Simple.

boolean 

Simple.

big_number 

Simple.

null 

Simple.

blob_error 

Simple.

verbatim_string 

Simple.

blob_string 

Simple.

streamed_string 

Simple.

streamed_string_part 

Simple.

invalid 

Invalid.

Definition at line 22 of file type.hpp.

Function Documentation

◆ logger()

boost::redis::logger::logger ( level  l = level::disabled)
inline

Constructor.

Parameters
lLog level.

Definition at line 67 of file logger.hpp.

◆ on_connect()

void boost::redis::logger::on_connect ( system::error_code const &  ec,
asio::ip::tcp::endpoint const &  ep 
)

Called when the connect operation completes.

Parameters
ecError returned by the connect operation.
epEndpoint to which the connection connected.

◆ on_connection_lost()

void boost::redis::logger::on_connection_lost ( system::error_code const &  ec)

Called when the connection is lost.

Parameters
ecError returned when the connection is lost.

◆ on_hello()

void boost::redis::logger::on_hello ( system::error_code const &  ec,
generic_response const &  resp 
)

Called when the HELLO request completes.

Parameters
ecError code returned by the async_exec operation.
respResponse sent by the Redis server.

◆ on_read()

void boost::redis::logger::on_read ( system::error_code const &  ec,
std::size_t  n 
)

Called when the read operation completes.

Parameters
ecError code returned by the read operation.
nNumber of bytes read.

◆ on_resolve()

void boost::redis::logger::on_resolve ( system::error_code const &  ec,
asio::ip::tcp::resolver::results_type const &  res 
)

Called when the resolve operation completes.

Parameters
ecError returned by the resolve operation.
resResolve results.

◆ on_run()

void boost::redis::logger::on_run ( system::error_code const &  reader_ec,
system::error_code const &  writer_ec 
)

Called when the run operation completes.

Parameters
reader_ecError code returned by the read operation.
writer_ecError code returned by the write operation.

◆ on_runner()

void boost::redis::logger::on_runner ( system::error_code const &  run_all_ec,
system::error_code const &  health_check_ec,
system::error_code const &  hello_ec 
)

Called when the runner operation completes.

Parameters
run_all_ecError code returned by the run_all operation.
health_check_ecError code returned by the health checker operation.
hello_ecError code returned by the health checker operation.

◆ on_ssl_handshake()

void boost::redis::logger::on_ssl_handshake ( system::error_code const &  ec)

Called when the ssl handshake operation completes.

Parameters
ecError returned by the handshake operation.

◆ on_write()

void boost::redis::logger::on_write ( system::error_code const &  ec,
std::string const &  payload 
)

Called when the write operation completes.

Parameters
ecError code returned by the write operation.
payloadThe payload written to the socket.

◆ operator<<()

auto boost::redis::resp3::operator<< ( std::ostream &  os,
type  t 
) -> std::ostream &

Writes the type to the output stream.

Parameters
osOutput stream.
tRESP3 type.

◆ set_prefix()

void boost::redis::logger::set_prefix ( std::string_view  prefix)
inline

Sets a prefix to every log message.

Parameters
prefixThe prefix.

Definition at line 138 of file logger.hpp.

◆ to_string()

auto boost::redis::resp3::to_string ( type  t) -> char const *
noexcept

Converts the data type to a string.

Parameters
tRESP3 type.

Variable Documentation

◆ ignore

ignore_t boost::redis::ignore
extern

Global ignore object.

Can be used to ignore responses to a request

conn->async_exec(req, ignore, ...);
ignore_t ignore
Global ignore object.

RESP3 errors won't be ignore but will cause async_exec to complete with an error.