Add hgetall / hincrby

This commit is contained in:
fbraem
2015-11-17 22:02:25 +01:00
parent 8d08cc3909
commit 2f850b8a43
4 changed files with 135 additions and 0 deletions

View File

@@ -158,6 +158,24 @@ Command Command::hget(const std::string& hash, const std::string& field)
return cmd;
}
Command Command::hgetall(const std::string& hash)
{
Command cmd("HGETALL");
cmd << hash;
return cmd;
}
Command Command::hincrby(const std::string& hash, const std::string& field, Int64 by)
{
Command cmd("HINCRBY");
cmd << hash << field << NumberFormatter::format(by);
return cmd;
}
Command Command::hset(const std::string& hash, const std::string& field, const std::string& value, bool create)
{
Command cmd(create ? "HSET" : "HSETNX");
@@ -167,6 +185,11 @@ Command Command::hset(const std::string& hash, const std::string& field, const s
return cmd;
}
Command Command::hset(const std::string& hash, const std::string& field, Int64 value, bool create)
{
return hset(hash, field, NumberFormatter::format(value), create);
}
Command Command::incr(const std::string& key, Int64 by)
{
Command cmd(by == 0 ? "INCR" : "INCRBY");