Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

Commit

Permalink
Z set functions floating point value handling (#45)
Browse files Browse the repository at this point in the history
* update Z** functions such that min/max parameters are no longer ints but strings such that float can be passed in with exact value (no conversion precision lost during float to string)

* Z** functions are now string/int/double
  • Loading branch information
Cylix authored Feb 6, 2017
1 parent 9894d69 commit 16b6b5d
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 0 deletions.
64 changes: 64 additions & 0 deletions includes/cpp_redis/future_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,18 +791,50 @@ class future_client {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zcount(key, min, max, cb); });
}
future
zcount(const std::string& key, double min, double max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zcount(key, min, max, cb); });
}
future
zcount(const std::string& key, const std::string& min, const std::string& max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zcount(key, min, max, cb); });
}
future
zincrby(const std::string& key, int incr, const std::string& member) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zincrby(key, incr, member, cb); });
}
future
zincrby(const std::string& key, double incr, const std::string& member) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zincrby(key, incr, member, cb); });
}
future
zincrby(const std::string& key, const std::string& incr, const std::string& member) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zincrby(key, incr, member, cb); });
}
// future zinterstore() destination numkeys key [key ...] [weights weight [weight ...]] [aggregate sum|min|max]
future
zlexcount(const std::string& key, int min, int max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zlexcount(key, min, max, cb); });
}
future
zlexcount(const std::string& key, double min, double max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zlexcount(key, min, max, cb); });
}
future
zlexcount(const std::string& key, const std::string& min, const std::string& max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zlexcount(key, min, max, cb); });
}
future
zrange(const std::string& key, int start, int stop, bool withscores = false) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zrange(key, start, stop, withscores, cb); });
}
future
zrange(const std::string& key, double start, double stop, bool withscores = false) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zrange(key, start, stop, withscores, cb); });
}
future
zrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zrange(key, start, stop, withscores, cb); });
}
// future zrangebylex() key min max [limit offset count]
// future zrevrangebylex() key max min [limit offset count]
// future zrangebyscore() key min max [withscores] [limit offset count]
Expand All @@ -819,17 +851,49 @@ class future_client {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebylex(key, min, max, cb); });
}
future
zremrangebylex(const std::string& key, double min, double max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebylex(key, min, max, cb); });
}
future
zremrangebylex(const std::string& key, const std::string& min, const std::string& max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebylex(key, min, max, cb); });
}
future
zremrangebyrank(const std::string& key, int start, int stop) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebyrank(key, start, stop, cb); });
}
future
zremrangebyrank(const std::string& key, double start, double stop) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebyrank(key, start, stop, cb); });
}
future
zremrangebyrank(const std::string& key, const std::string& start, const std::string& stop) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebyrank(key, start, stop, cb); });
}
future
zremrangebyscore(const std::string& key, int min, int max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebyscore(key, min, max, cb); });
}
future
zremrangebyscore(const std::string& key, double min, double max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebyscore(key, min, max, cb); });
}
future
zremrangebyscore(const std::string& key, const std::string& min, const std::string& max) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zremrangebyscore(key, min, max, cb); });
}
future
zrevrange(const std::string& key, int start, int stop, bool withscores = false) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zrevrange(key, start, stop, withscores, cb); });
}
future
zrevrange(const std::string& key, double start, double stop, bool withscores = false) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zrevrange(key, start, stop, withscores, cb); });
}
future
zrevrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false) {
return exec_cmd([=](const rcb_t& cb) -> rc& { return m_client.zrevrange(key, start, stop, withscores, cb); });
}
// future zrevrangebyscore() key max min [withscores] [limit offset count]
future
zrevrank(const std::string& key, const std::string& member) {
Expand Down
16 changes: 16 additions & 0 deletions includes/cpp_redis/redis_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,35 @@ class redis_client {
// redis_client& zadd(const reply_callback_t& reply_callback = nullptr) key [nx|xx] [ch] [incr] score member [score member ...]
redis_client& zcard(const std::string& key, const reply_callback_t& reply_callback = nullptr);
redis_client& zcount(const std::string& key, int min, int max, const reply_callback_t& reply_callback = nullptr);
redis_client& zcount(const std::string& key, double min, double max, const reply_callback_t& reply_callback = nullptr);
redis_client& zcount(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback = nullptr);
redis_client& zincrby(const std::string& key, int incr, const std::string& member, const reply_callback_t& reply_callback = nullptr);
redis_client& zincrby(const std::string& key, double incr, const std::string& member, const reply_callback_t& reply_callback = nullptr);
redis_client& zincrby(const std::string& key, const std::string& incr, const std::string& member, const reply_callback_t& reply_callback = nullptr);
// redis_client& zinterstore(const reply_callback_t& reply_callback = nullptr) destination numkeys key [key ...] [weights weight [weight ...]] [aggregate sum|min|max]
redis_client& zlexcount(const std::string& key, int min, int max, const reply_callback_t& reply_callback = nullptr);
redis_client& zlexcount(const std::string& key, double min, double max, const reply_callback_t& reply_callback = nullptr);
redis_client& zlexcount(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback = nullptr);
redis_client& zrange(const std::string& key, int start, int stop, bool withscores = false, const reply_callback_t& reply_callback = nullptr);
redis_client& zrange(const std::string& key, double start, double stop, bool withscores = false, const reply_callback_t& reply_callback = nullptr);
redis_client& zrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false, const reply_callback_t& reply_callback = nullptr);
// redis_client& zrangebylex(const reply_callback_t& reply_callback = nullptr) key min max [limit offset count]
// redis_client& zrevrangebylex(const reply_callback_t& reply_callback = nullptr) key max min [limit offset count]
// redis_client& zrangebyscore(const reply_callback_t& reply_callback = nullptr) key min max [withscores] [limit offset count]
redis_client& zrank(const std::string& key, const std::string& member, const reply_callback_t& reply_callback = nullptr);
redis_client& zrem(const std::string& key, const std::vector<std::string>& members, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebylex(const std::string& key, int min, int max, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebylex(const std::string& key, double min, double max, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebylex(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebyrank(const std::string& key, int start, int stop, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebyrank(const std::string& key, double start, double stop, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebyrank(const std::string& key, const std::string& start, const std::string& stop, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebyscore(const std::string& key, int min, int max, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebyscore(const std::string& key, double min, double max, const reply_callback_t& reply_callback = nullptr);
redis_client& zremrangebyscore(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback = nullptr);
redis_client& zrevrange(const std::string& key, int start, int stop, bool withscores = false, const reply_callback_t& reply_callback = nullptr);
redis_client& zrevrange(const std::string& key, double start, double stop, bool withscores = false, const reply_callback_t& reply_callback = nullptr);
redis_client& zrevrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false, const reply_callback_t& reply_callback = nullptr);
// redis_client& zrevrangebyscore(const reply_callback_t& reply_callback = nullptr) key max min [withscores] [limit offset count]
redis_client& zrevrank(const std::string& key, const std::string& member, const reply_callback_t& reply_callback = nullptr);
redis_client& zscore(const std::string& key, const std::string& member, const reply_callback_t& reply_callback = nullptr);
Expand Down
64 changes: 64 additions & 0 deletions includes/cpp_redis/sync_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,18 +771,50 @@ class sync_client {
return m_client.zcount(key, min, max).get();
}
reply
zcount(const std::string& key, double min, double max) {
return m_client.zcount(key, min, max).get();
}
reply
zcount(const std::string& key, const std::string& min, const std::string& max) {
return m_client.zcount(key, min, max).get();
}
reply
zincrby(const std::string& key, int incr, const std::string& member) {
return m_client.zincrby(key, incr, member).get();
}
reply
zincrby(const std::string& key, double incr, const std::string& member) {
return m_client.zincrby(key, incr, member).get();
}
reply
zincrby(const std::string& key, const std::string& incr, const std::string& member) {
return m_client.zincrby(key, incr, member).get();
}
// reply zinterstore() dest numkeys key [key ...] [weights weight [weight ...]] [aggregate sum|min|max]
reply
zlexcount(const std::string& key, int min, int max) {
return m_client.zlexcount(key, min, max).get();
}
reply
zlexcount(const std::string& key, double min, double max) {
return m_client.zlexcount(key, min, max).get();
}
reply
zlexcount(const std::string& key, const std::string& min, const std::string& max) {
return m_client.zlexcount(key, min, max).get();
}
reply
zrange(const std::string& key, int start, int stop, bool withscores = false) {
return m_client.zrange(key, start, stop, withscores).get();
}
reply
zrange(const std::string& key, double start, double stop, bool withscores = false) {
return m_client.zrange(key, start, stop, withscores).get();
}
reply
zrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false) {
return m_client.zrange(key, start, stop, withscores).get();
}
// reply zrangebylex() key min max [limit offset count]
// reply zrevrangebylex() key max min [limit offset count]
// reply zrangebyscore() key min max [withscores] [limit offset count]
Expand All @@ -799,17 +831,49 @@ class sync_client {
return m_client.zremrangebylex(key, min, max).get();
}
reply
zremrangebylex(const std::string& key, double min, double max) {
return m_client.zremrangebylex(key, min, max).get();
}
reply
zremrangebylex(const std::string& key, const std::string& min, const std::string& max) {
return m_client.zremrangebylex(key, min, max).get();
}
reply
zremrangebyrank(const std::string& key, int start, int stop) {
return m_client.zremrangebyrank(key, start, stop).get();
}
reply
zremrangebyrank(const std::string& key, double start, double stop) {
return m_client.zremrangebyrank(key, start, stop).get();
}
reply
zremrangebyrank(const std::string& key, const std::string& start, const std::string& stop) {
return m_client.zremrangebyrank(key, start, stop).get();
}
reply
zremrangebyscore(const std::string& key, int min, int max) {
return m_client.zremrangebyscore(key, min, max).get();
}
reply
zremrangebyscore(const std::string& key, double min, double max) {
return m_client.zremrangebyscore(key, min, max).get();
}
reply
zremrangebyscore(const std::string& key, const std::string& min, const std::string& max) {
return m_client.zremrangebyscore(key, min, max).get();
}
reply
zrevrange(const std::string& key, int start, int stop, bool withscores = false) {
return m_client.zrevrange(key, start, stop, withscores).get();
}
reply
zrevrange(const std::string& key, double start, double stop, bool withscores = false) {
return m_client.zrevrange(key, start, stop, withscores).get();
}
reply
zrevrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false) {
return m_client.zrevrange(key, start, stop, withscores).get();
}
// reply zrevrangebyscore() key max min [withscores] [limit offset count]
reply
zrevrank(const std::string& key, const std::string& member) {
Expand Down
Loading

0 comments on commit 16b6b5d

Please sign in to comment.