Skip to content

Commit

Permalink
Added SortedSet#member? and CoreCommands#ttl per Karl Varga
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Wiger committed Jul 21, 2011
1 parent ae596a0 commit eb4485f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
= Changelog for Redis::Objects

== 0.5.2 [Development]

* Added Redis::SortedSet#member? method [Karl Varga]

* Added +ttl+ method to CoreCommands [Karl Varga]

== 0.5.1 [Final] (23 May 2011)

* Fixed super class delegation conflicts with Redis Counters vs ActiveRecord [Tim Aßmann]
Expand Down
6 changes: 5 additions & 1 deletion lib/redis/helpers/core_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def expire(seconds)
def expireat(unixtime)
redis.expire key, unixtime
end


def ttl
redis.ttl(@key).seconds
end

def move(dbindex)
redis.move key, dbindex
end
Expand Down
5 changes: 5 additions & 0 deletions lib/redis/sorted_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ def range_size(min, max)
redis.zcount(key, min, max)
end

# Return a boolean indicating whether +value+ is a member.
def member?(value)
!redis.zscore(key, to_redis(value)).nil?
end

private

def keys_from_objects(sets)
Expand Down

0 comments on commit eb4485f

Please sign in to comment.