Add blpop / brpop / brpoplpush

This commit is contained in:
fbraem
2015-11-14 19:39:16 +01:00
parent ed0b61c6e1
commit 4e5fe3f874
4 changed files with 161 additions and 0 deletions

View File

@@ -43,6 +43,41 @@ Command Command::append(const std::string& key, const std::string& value)
return cmd;
}
Command Command::blpop(const std::vector<std::string>& lists, Int64 timeout)
{
Command cmd("BLPOP");
for(std::vector<std::string>::const_iterator it = lists.begin(); it != lists.end(); ++it)
{
cmd << *it;
}
cmd << NumberFormatter::format(timeout);
return cmd;
}
Command Command::brpop(const std::vector<std::string>& lists, Int64 timeout)
{
Command cmd("BRPOP");
for(std::vector<std::string>::const_iterator it = lists.begin(); it != lists.end(); ++it)
{
cmd << *it;
}
cmd << NumberFormatter::format(timeout);
return cmd;
}
Command Command::brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout)
{
Command cmd("BRPOPLPUSH");
cmd << sourceList << destinationList << NumberFormatter::format(timeout);
return cmd;
}
Command Command::decr(const std::string& key, Int64 by)
{
Command cmd(by == 0 ? "DECR" : "DECRBY");