Skip to content

Commit

Permalink
Merge pull request #141 from ekyo/master
Browse files Browse the repository at this point in the history
redis.ttl fix for expired keys. + potential implementation of redis.zrangebyscore
  • Loading branch information
s-ludwig committed Dec 1, 2012
2 parents 141ba08 + 39a44f0 commit cedc978
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions source/vibe/db/redis/redis.d
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ final class RedisClient {

//TODO sort

size_t ttl(string key) {
return request!size_t("TTL", cast(ubyte[])key);
long ttl(string key) {
return request!long("TTL", cast(ubyte[])key);
}

string type(string key) {
Expand Down Expand Up @@ -432,7 +432,18 @@ final class RedisClient {
return request("ZRANGE", args);
}

//TODO: zrangeByScore
RedisReply zrangeByScore(string key, size_t start, size_t end, bool withScores=false) {
ubyte[][] args = [cast(ubyte[])key, cast(ubyte[])to!string(start), cast(ubyte[])to!string(end)];
if (withScores) args ~= cast(ubyte[])"WITHSCORES";
return request("ZRANGEBYSCORE", args);
}

RedisReply zrangeByScore(string key, size_t start, size_t end, size_t offset, size_t count, bool withScores=false) {
ubyte[][] args = [cast(ubyte[])key, cast(ubyte[])to!string(start), cast(ubyte[])to!string(end)];
if (withScores) args ~= cast(ubyte[])"WITHSCORES";
args ~= cast(ubyte[])"LIMIT" ~ cast(ubyte[])to!string(offset) ~ cast(ubyte[])to!string(count);
return request("ZRANGEBYSCORE", args);
}

int zrank(string key, string member) {
auto str = request!string("ZRANK", cast(ubyte[]) key, cast(ubyte[]) member);
Expand All @@ -447,7 +458,7 @@ final class RedisClient {
return request!size_t("ZREMRANGEBYRANK", cast(ubyte[])key, cast(ubyte[])to!string(start), cast(ubyte[])to!string(stop));
}

size_t zremRangeByScore(string key, double min, double max) {
size_t zremRangeByScore(string key, double min, double max) {
return request!size_t("ZREMRANGEBYSCORE", cast(ubyte[])key, cast(ubyte[])to!string(min), cast(ubyte[])to!string(max));
}

Expand Down

0 comments on commit cedc978

Please sign in to comment.