Reference
boost::redis::consume_one
Consume on response from a generic response
Synopsis
Declared in <boost/redis/response.hpp>
void
consume_one(
generic_response& r,
system::error_code& ec);
Description
This function rotates the elements so that the start of the next response becomes the new front element. For example the output of the following code
request req;
req.push("PING", "one");
req.push("PING", "two");
req.push("PING", "three");
generic_response resp;
co_await conn.async_exec(req, resp);
std::cout << "PING: " << resp.value().front().value << std::endl;
consume_one(resp);
std::cout << "PING: " << resp.value().front().value << std::endl;
consume_one(resp);
std::cout << "PING: " << resp.value().front().value << std::endl;
Is:
PING: one
PING: two
PING: three
Given that this function rotates elements, it won't be very efficient for responses with a large number of elements. It was introduced mainly to deal with buffers server pushes as shown in the cpp20_subscriber.cpp example. In the future queue‐like responses might be introduced to consume in O(1) operations.
Parameters
Name |
Description |
r |
The response to modify. |
ec |
Will be populated in case of error. |
Created with MrDocs