From 434805661c532dcb3c6af69768a9bf70ba79297b Mon Sep 17 00:00:00 2001 From: "Jens K. Mueller" Date: Sat, 26 Apr 2014 10:40:28 +0200 Subject: [PATCH 1/4] Fix typo --- source/vibe/db/redis/redis.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/vibe/db/redis/redis.d b/source/vibe/db/redis/redis.d index 3e7efb30b4..055aa50e22 100644 --- a/source/vibe/db/redis/redis.d +++ b/source/vibe/db/redis/redis.d @@ -302,7 +302,7 @@ struct RedisDatabase { Sorted Sets */ - long zadd(ARGS...)(string key, ARGS args) { return request!long("SADD", key, args); } + long zadd(ARGS...)(string key, ARGS args) { return request!long("ZADD", key, args); } long Zcard(string key) { return request!long("ZCARD", key); } long zcount(string key, double min, double max) { return request!long("ZCOUNT", key, min, max); } double zincrby(string key, double value, string member) { return request!double("ZINCRBY", value, member); } From a3bd85c4d3890be23f9eb6aeed119bf68c5f2adc Mon Sep 17 00:00:00 2001 From: "Jens K. Mueller" Date: Sat, 26 Apr 2014 10:41:37 +0200 Subject: [PATCH 2/4] Fix signature --- source/vibe/db/redis/redis.d | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/vibe/db/redis/redis.d b/source/vibe/db/redis/redis.d index 055aa50e22..78ba49454a 100644 --- a/source/vibe/db/redis/redis.d +++ b/source/vibe/db/redis/redis.d @@ -313,13 +313,15 @@ struct RedisDatabase { return request!RedisReply("ZRANGE", args); } - RedisReply zrangeByScore(string key, long start, long end, bool withScores=false) { + RedisReply zrangeByScore(string key, double start, double end, bool withScores=false) { string[] args = [key, to!string(start), to!string(end)]; if (withScores) args ~= "WITHSCORES"; return request!RedisReply("ZRANGEBYSCORE", args); } - RedisReply zrangeByScore(string key, long start, long end, long offset, long count, bool withScores=false) { + RedisReply zrangeByScore(string key, double start, double end, long offset, long count, bool withScores=false) { + assert(offset >= 0); + assert(count >= 0); string[] args = [key, to!string(start), to!string(end)]; if (withScores) args ~= "WITHSCORES"; args ~= ["LIMIT", to!string(offset), to!string(count)]; From 6adeb52accd51b2ef5c65b4bbdc0960ac43d129c Mon Sep 17 00:00:00 2001 From: "Jens K. Mueller" Date: Sat, 26 Apr 2014 10:45:00 +0200 Subject: [PATCH 3/4] Add zrevRangeByScore with offset and count --- source/vibe/db/redis/redis.d | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/vibe/db/redis/redis.d b/source/vibe/db/redis/redis.d index 78ba49454a..baae943a21 100644 --- a/source/vibe/db/redis/redis.d +++ b/source/vibe/db/redis/redis.d @@ -348,6 +348,15 @@ struct RedisDatabase { return request!RedisReply("ZREVRANGEBYSCORE", args); } + RedisReply zrevRangeByScore(string key, double min, double max, long offset, long count, bool withScores=false) { + assert(offset >= 0); + assert(count >= 0); + string[] args = [key, to!string(min), to!string(max)]; + if (withScores) args ~= "WITHSCORES"; + args ~= ["LIMIT", to!string(offset), to!string(count)]; + return request!RedisReply("ZREVRANGEBYSCORE", args); + } + long zrevRank(string key, string member) { auto str = request!string("ZREVRANK", key, member); return str ? parse!long(str) : -1; From 2ab1b70ff88bc3d37ad00ea49e7d7f606f50055c Mon Sep 17 00:00:00 2001 From: "Jens K. Mueller" Date: Sat, 26 Apr 2014 10:45:54 +0200 Subject: [PATCH 4/4] Add comments --- source/vibe/db/redis/redis.d | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/vibe/db/redis/redis.d b/source/vibe/db/redis/redis.d index baae943a21..ebff4f4ba4 100644 --- a/source/vibe/db/redis/redis.d +++ b/source/vibe/db/redis/redis.d @@ -304,6 +304,9 @@ struct RedisDatabase { long zadd(ARGS...)(string key, ARGS args) { return request!long("ZADD", key, args); } long Zcard(string key) { return request!long("ZCARD", key); } + // TODO: + // supports only inclusive intervals + // see http://redis.io/commands/zrangebyscore long zcount(string key, double min, double max) { return request!long("ZCOUNT", key, min, max); } double zincrby(string key, double value, string member) { return request!double("ZINCRBY", value, member); } //TODO: zinterstore @@ -313,12 +316,18 @@ struct RedisDatabase { return request!RedisReply("ZRANGE", args); } + // TODO: + // supports only inclusive intervals + // see http://redis.io/commands/zrangebyscore RedisReply zrangeByScore(string key, double start, double end, bool withScores=false) { string[] args = [key, to!string(start), to!string(end)]; if (withScores) args ~= "WITHSCORES"; return request!RedisReply("ZRANGEBYSCORE", args); } + // TODO: + // supports only inclusive intervals + // see http://redis.io/commands/zrangebyscore RedisReply zrangeByScore(string key, double start, double end, long offset, long count, bool withScores=false) { assert(offset >= 0); assert(count >= 0); @@ -334,6 +343,9 @@ struct RedisDatabase { } long zrem(string key, string[] members...) { return request!long("ZREM", key, members); } long zremRangeByRank(string key, long start, long stop) { return request!long("ZREMRANGEBYRANK", key, start, stop); } + // TODO: + // supports only inclusive intervals + // see http://redis.io/commands/zrangebyscore long zremRangeByScore(string key, double min, double max) { return request!long("ZREMRANGEBYSCORE", key, min, max);} RedisReply zrevRange(string key, long start, long end, bool withScores=false) { @@ -342,12 +354,18 @@ struct RedisDatabase { return request!RedisReply("ZREVRANGE", args); } + // TODO: + // supports only inclusive intervals + // see http://redis.io/commands/zrangebyscore RedisReply zrevRangeByScore(string key, double min, double max, bool withScores=false) { string[] args = [key, to!string(min), to!string(max)]; if (withScores) args ~= "WITHSCORES"; return request!RedisReply("ZREVRANGEBYSCORE", args); } + // TODO: + // supports only inclusive intervals + // see http://redis.io/commands/zrangebyscore RedisReply zrevRangeByScore(string key, double min, double max, long offset, long count, bool withScores=false) { assert(offset >= 0); assert(count >= 0);