Reference

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", std::cbegin(channels), std::cend(channels));

Command arguments should either be convertible to std::string_view or support the boost_redis_to_bulk function. This function is a customization point that must be made available using ADL and must have the following signature:

void boost_redis_to_bulk(std::string& to, T const& t);

See cpp20_serialization.cpp

Template Parameters

Name

Description

ForwardIterator

A forward iterator with an element type that is convertible to std::string_view or supports boost_redis_to_bulk.

Parameters

Name

Description

cmd

The command to execute. It should be a redis or sentinel command, like "SET".

begin

Iterator to the begin of the range.

end

Iterator to the end of the range.

Created with MrDocs