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

Some redis fixes #636

Closed
wants to merge 4 commits into from
Closed
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
31 changes: 28 additions & 3 deletions source/vibe/db/redis/redis.d
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ 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); }
// 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
Expand All @@ -313,13 +316,19 @@ struct RedisDatabase {
return request!RedisReply("ZRANGE", args);
}

RedisReply zrangeByScore(string key, long start, long end, bool withScores=false) {
// 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);
}

RedisReply zrangeByScore(string key, long start, long end, long offset, long count, bool withScores=false) {
// TODO:
// supports only inclusive intervals
// see http://redis.io/commands/zrangebyscore
RedisReply zrangeByScore(string key, double start, double end, size_t offset, size_t count, bool withScores=false) {
string[] args = [key, to!string(start), to!string(end)];
if (withScores) args ~= "WITHSCORES";
args ~= ["LIMIT", to!string(offset), to!string(count)];
Expand All @@ -332,6 +341,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) {
Expand All @@ -340,12 +352,25 @@ 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, size_t offset, size_t count, bool withScores=false) {
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;
Expand Down