boost::redis::request::push_range
Appends a new command to the end of the request.
Synopsis
Declared in <boost/redis/request.hpp>
template<class ForwardIterator>
void
push_range(
std::string_view cmd,
ForwardIterator begin,
ForwardIterator end,
std::iterator_traits<ForwardIterator>::value_type* = nullptr);
Description
This overload is useful for commands that have a dynamic number of arguments and don't have a key. For example:
std::set<std::string> channels
{ "channel1" , "channel2" , "channel3" };
request req;
req.push("SUBSCRIBE", channels.cbegin(), channels.cend());
This will generate the following command:
SUBSCRIBE channel1 channel2 channel3
If the passed range is empty, no command is added and this function becomes a no‐op.
The value type of the passed range should satisfy one of the following:
-
The type is convertible to `std::string_view`. One argument is added per element in the range.
-
The type is an integral type. One argument is added per element in the range.
-
The type supports the `boost_redis_to_bulk` function. One argument is added per element in the range. This function is a customization point that must be made available using ADL and must have the signature `void boost_redis_to_bulk(std::string& to, T const& t);`.
-
The type is a `std::pair` instantiation, with both arguments supporting one of the points above. Two arguments are added per element in the range. Nested pairs are not allowed.
-
The type is a `std::tuple` instantiation, with every argument supporting one of the points above. N arguments are added per element in the range, with N being the tuple size. Nested tuples are not allowed.
See cpp20_serialization.cpp
Template Parameters
| Name | Description |
|---|---|
ForwardIterator |
A forward iterator with an element type that supports one of the points above. |
Parameters
| Name | Description |
|---|---|
cmd |
The command to execute. It should be a redis or sentinel command, like |
begin |
Iterator to the begin of the range. |
end |
Iterator to the end of the range. |
Created with MrDocs