Open zlausd opened 1 week ago
Modifying test_set
to run commands as individual requests works as one would expect
Not contained in TEST_SET: z
Not contained in TEST_SET:
auto test_set(std::shared_ptr<connection> conn, std::vector<std::string> query_data) -> awaitable<void>
{
{
request req;
req.push_range("SADD", "TMP_SET", query_data);
co_await conn->async_exec(req, ignore, deferred);
}
{
request req;
req.push("SDIFF", "TMP_SET", "TEST_SET");
response<std::vector<std::string>> resp;
co_await conn->async_exec(req, resp, deferred);
auto not_contained_values = std::get<0>(resp).value();
std::cout << "Not contained in TEST_SET: ";
print(not_contained_values);
}
{
request req;
req.push("ECHO", "this_should_not_be_in_set");
co_await conn->async_exec(req, ignore, deferred);
}
{
request req;
req.push("DEL", "TMP_SET");
co_await conn->async_exec(req, ignore, deferred);
}
}
Edit: Not using MULTI/EXEC and putting everything into one request also seems to work fine.
auto test_intersection(std::shared_ptr<connection> conn, std::vector<std::string> query_data) -> awaitable<void>
{
request req;
req.push_range("SADD", "TMP_SET", query_data);
req.push("SDIFF", "TMP_SET", "TEST_SET");
req.push("ECHO", "this_should_not_be_in_set");
req.push("DEL", "TMP_SET");
response<ignore_t, std::vector<std::string>, ignore_t, ignore_t > resp;
co_await conn->async_exec(req, resp, deferred);
auto not_contained_values = std::get<1>(resp).value();
std::cout << "Not contained in TEST_SET: ";
print(not_contained_values);
}
Hi, thanks for reporting. I will have a look at it on this weekend. For now you could check if the generic_response
solves the problem for you.
Let me preface the bug report that I may be doing something horribly wrong and misusing the library.
Now that thats out of the way, lets start off at redis/redis-cli level and lower the description of the observation towards the output seen in C++ and at the very end is the code sample that replicates this behavior.
Lets create a dummy test set
SADD TEST_SET a b c d e f g
redis-cli output
And intersect it with a temporary set that contains the values a and z.
redis-cli output
Everything looks fine and this works when translated into the same C++ code. The issue starts when the intersection is empty as the follow up command response is parsed to the member representing SDIFF.
redis-cli output
The result of the SDIFF operator when I translate the above two MULTI transactions into boost/redis is as follows:
Appreciate any feedback as to what I am doing wrong. Changing the type to either
std::set<std::string>
orstd::optional<std::vector<std::string>>
gives the same behavior.Code: