Class: RedSetMulti
- Inherits:
-
Object
- Object
- RedSetMulti
- Defined in:
- lib/redness/red_set_multi.rb
Instance Attribute Summary collapse
-
#keys ⇒ Object
Returns the value of attribute keys.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
- #get(options = {}) ⇒ Object
-
#initialize(*keys) ⇒ RedSetMulti
constructor
A new instance of RedSetMulti.
Constructor Details
#initialize(*keys) ⇒ RedSetMulti
Returns a new instance of RedSetMulti.
4 5 6 7 |
# File 'lib/redness/red_set_multi.rb', line 4 def initialize(*keys) self.keys = keys self.redis = Red.new end |
Instance Attribute Details
#keys ⇒ Object
Returns the value of attribute keys.
2 3 4 |
# File 'lib/redness/red_set_multi.rb', line 2 def keys @keys end |
#redis ⇒ Object
Returns the value of attribute redis.
2 3 4 |
# File 'lib/redness/red_set_multi.rb', line 2 def redis @redis end |
Instance Method Details
#get(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/redness/red_set_multi.rb', line 9 def get( = {}) lower_bound = [:lower] || 0 upper_bound = [:upper] || -1 redis.execute_with_uncertainty([]) do results = keys.map { |key| redis.zrevrange(key, lower_bound, upper_bound) } if results.present? results.map {|r| r.map(&:to_i)} else [] end end end |