Module: Redis::ExpiringSetMethods
- Included in:
- Redis, ExpiringSet
- Defined in:
- lib/redis-expiring-set.rb
Instance Method Summary collapse
- #xadd(key, value, expires) ⇒ Object
- #xcard(key) ⇒ Object
- #xclearexpired(key) ⇒ Object
- #xmembers(key) ⇒ Object
- #xrem(key, value) ⇒ Object
Instance Method Details
#xadd(key, value, expires) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/redis-expiring-set.rb', line 9 def xadd(key, value, expires) if expires.is_a? Numeric expires = Time.now + expires end zadd(key, expires.to_f, value) end |
#xcard(key) ⇒ Object
30 31 32 33 |
# File 'lib/redis-expiring-set.rb', line 30 def xcard(key) xclearexpired(key) zcard(key) end |
#xclearexpired(key) ⇒ Object
26 27 28 |
# File 'lib/redis-expiring-set.rb', line 26 def xclearexpired(key) zremrangebyscore key, -Float::INFINITY, Time.now.to_f.to_i end |
#xmembers(key) ⇒ Object
21 22 23 24 |
# File 'lib/redis-expiring-set.rb', line 21 def xmembers(key) xclearexpired(key) zrangebyscore(key, -Float::INFINITY, Float::INFINITY) end |
#xrem(key, value) ⇒ Object
17 18 19 |
# File 'lib/redis-expiring-set.rb', line 17 def xrem(key, value) zrem(key, value) end |