Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async redis reply #555

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/sw/redis++/reply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ std::string parse(ParseTag<std::string>, redisReply &reply) {
return std::string(reply.str, reply.len);
}

redisReply* parse(ParseTag<redisReply*>, redisReply &reply) {
return &reply;
}

long long parse(ParseTag<long long>, redisReply &reply) {
if (!reply::is_integer(reply)) {
throw ParseError("INTEGER", reply);
Expand Down
2 changes: 2 additions & 0 deletions src/sw/redis++/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ long long parse(ParseTag<long long>, redisReply &reply);

double parse(ParseTag<double>, redisReply &reply);

redisReply* parse(ParseTag<redisReply*>, redisReply &reply);

bool parse(ParseTag<bool>, redisReply &reply);

template <typename T>
Expand Down
13 changes: 13 additions & 0 deletions test/src/sw/redis++/async_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,19 @@ void AsyncTest<RedisInstance>::_test_generic() {

_redis.template command<long long>("del", key);

val = "rawReply";
args = {"set", key, val};
auto raw_resp =_redis.template command<redisReply*>(args.begin(), args.end()).get();
REDIS_ASSERT(raw_resp->type == REDIS_REPLY_STATUS, "unexpected return type");

args = {"get", key};
raw_resp =_redis.template command<redisReply*>(args.begin(), args.end()).get();
REDIS_ASSERT(raw_resp->type == REDIS_REPLY_STRING, "unexpected return type");

args = {"del", key};
raw_resp =_redis.template command<redisReply*>(args.begin(), args.end()).get();
REDIS_ASSERT(raw_resp->type == REDIS_REPLY_INTEGER, "unexpected return type");

std::unordered_set<std::string> mems = {"a", "b", "c"};
args = {"sadd", another_key};
args.insert(args.end(), mems.begin(), mems.end());
Expand Down