Class: Seymour::Store::Zset

Inherits:
Base
  • Object
show all
Defined in:
lib/seymour/store/zset.rb

Instance Attribute Summary

Attributes inherited from Base

#key

Instance Method Summary collapse

Methods inherited from Base

#activity_ids, #bulk_push, #initialize, #max_size, #redis, #remove

Constructor Details

This class inherits a constructor from Seymour::Store::Base

Instance Method Details

#idsObject



9
10
11
# File 'lib/seymour/store/zset.rb', line 9

def ids
  redis.zrevrange(key, 0, max_size).map(&:to_i)
end

#intersect(feeds, options = {}) ⇒ Object



25
26
27
# File 'lib/seymour/store/zset.rb', line 25

def intersect(feeds, options = {})
  redis.zinterstore key, feeds.map(&:key), options
end

#push(activity, score = activity.score) ⇒ Object



5
6
7
# File 'lib/seymour/store/zset.rb', line 5

def push(activity, score = activity.score)
  redis.zadd(key, score, activity.id)
end

#remove_id(id) ⇒ Object



13
14
15
# File 'lib/seymour/store/zset.rb', line 13

def remove_id(id)
  redis.zrem(key, id)
end

#union(feeds, options = { :exclude_options => true }) ⇒ Object



21
22
23
# File 'lib/seymour/store/zset.rb', line 21

def union(feeds, options = { :exclude_options => true })
  redis.zunionstore key, feeds.map(&:key), options
end

#union_keys(keys, options = {}) ⇒ Object



17
18
19
# File 'lib/seymour/store/zset.rb', line 17

def union_keys(keys, options = {})
  redis.zunionstore key, keys, options
end