boost_redis 1.4.2
A redis client library
|
Creates Redis requests. More...
#include <include/boost/redis/request.hpp>
Classes | |
struct | config |
Request configuration options. More... | |
Public Member Functions | |
request (config cfg=config{true, false, true, true}) | |
Constructor. More... | |
void | clear () |
Clears the request preserving allocated memory. | |
auto | get_config () const noexcept -> auto const & |
Returns a const reference to the config object. | |
auto | get_config () noexcept -> auto & |
Returns a reference to the config object. | |
template<class... Ts> | |
void | push (std::string_view cmd, Ts const &... args) |
Appends a new command to the end of the request. More... | |
template<class Range > | |
void | push_range (std::string_view cmd, Range const &range, decltype(std::cbegin(range)) *=nullptr) |
Appends a new command to the end of the request. More... | |
template<class ForwardIterator > | |
void | push_range (std::string_view const &cmd, ForwardIterator begin, ForwardIterator end, typename std::iterator_traits< ForwardIterator >::value_type *=nullptr) |
Appends a new command to the end of the request. More... | |
template<class ForwardIterator > | |
void | push_range (std::string_view const &cmd, std::string_view const &key, ForwardIterator begin, ForwardIterator end, typename std::iterator_traits< ForwardIterator >::value_type *=nullptr) |
Appends a new command to the end of the request. More... | |
template<class Range > | |
void | push_range (std::string_view const &cmd, std::string_view const &key, Range const &range, decltype(std::begin(range)) *=nullptr) |
Appends a new command to the end of the request. More... | |
void | reserve (std::size_t new_cap=0) |
Calls std::string::reserve on the internal storage. | |
Related Functions | |
(Note that these are not member functions.) | |
void | boost_redis_to_bulk (std::string &payload, std::string_view data) |
Adds a bulk to the request. More... | |
Creates Redis requests.
A request is composed of one or more Redis commands and is referred to in the redis documentation as a pipeline, see https://redis.io/topics/pipelining. For example
Uses a std::string for internal storage.
Definition at line 46 of file request.hpp.
struct boost::redis::request::config |
Request configuration options.
Definition at line 49 of file request.hpp.
Class Members | ||
---|---|---|
bool | cancel_if_not_connected |
If true the request will complete with boost::redis::error::not_connected if async_exec is called before the connection with Redis was established. |
bool | cancel_if_unresponded |
If false boost::redis::connection::async_exec will not automatically cancel this request if the connection is lost. Affects only requests that have been written to the socket but remained unresponded when boost::redis::connection::async_run completed. |
bool | cancel_on_connection_lost |
If true boost::redis::connection::async_exec will complete with error if the connection is lost. Affects only requests that haven't been sent yet. |
bool | hello_with_priority |
If this request has a HELLO command and this flag is true , the boost::redis::connection will move it to the front of the queue of awaiting requests. This makes it possible to send HELLO and authenticate before other commands are sent. |
|
inline |
Appends a new command to the end of the request.
For example
will add the set
command with value "some string" and an expiration of 2 seconds.
cmd | The command e.g redis or sentinel command. |
args | Command arguments. |
Ts | Non-string types will be converted to string by calling boost_redis_to_bulk on each argument. This function must be made available over ADL and must have the following signature |
See cpp20_serialization.cpp
Definition at line 141 of file request.hpp.
|
inline |
Appends a new command to the end of the request.
Equivalent to the overload taking a range of begin and end iterators.
cmd | Redis command. |
range | Range to send e.g. std::map . |
A | type that can be passed to std::cbegin() and std::cend() . |
Definition at line 293 of file request.hpp.
|
inline |
Appends a new command to the end of the request.
This overload is useful for commands that have a dynamic number of arguments and don't have a key. For example
cmd | The Redis command |
begin | Iterator to the begin of the range. |
end | Iterator to the end of the range. |
ForwardIterator | If the value type is not a std::string it will be converted to a string by calling boost_redis_to_bulk . This function must be made available over ADL and must have the following signature |
See cpp20_serialization.cpp
Definition at line 237 of file request.hpp.
|
inline |
Appends a new command to the end of the request.
This overload is useful for commands that have a key and have a dynamic range of arguments. For example
cmd | The command e.g. Redis or Sentinel command. |
key | The command key. |
begin | Iterator to the begin of the range. |
end | Iterator to the end of the range. |
Ts | Non-string types will be converted to string by calling boost_redis_to_bulk on each argument. This function must be made available over ADL and must have the following signature |
See cpp20_serialization.cpp
Definition at line 184 of file request.hpp.
|
inline |
Appends a new command to the end of the request.
Equivalent to the overload taking a range of begin and end iterators.
cmd | Redis command. |
key | Redis key. |
range | Range to send e.g. std::map . |
A | type that can be passed to std::cbegin() and std::cend() . |
Definition at line 271 of file request.hpp.
|
related |
Adds a bulk to the request.
This function is useful in serialization of your own data structures in a request. For example
payload | Storage on which data will be copied into. |
data | Data that will be serialized and stored in payload . |
See more in serialization.