class RedList
Attributes
key[R]
Public Class Methods
add(key, value)
click to toggle source
# File lib/redness/red_list.rb, line 20 def self.add(key, value) redis.execute_with_uncertainty(false) do redis.lpush(key, value) end end
count(key, value)
click to toggle source
# File lib/redness/red_list.rb, line 32 def self.count(key, value) get(key).count(value) end
get(key)
click to toggle source
# File lib/redness/red_list.rb, line 8 def self.get(key) redis.execute_with_uncertainty([]) do redis.lrange(key, 0, -1).map(&:to_i) end end
get_strings(key)
click to toggle source
# File lib/redness/red_list.rb, line 14 def self.get_strings(key) redis.execute_with_uncertainty([]) do redis.lrange(key, 0, -1) end end
new(key)
click to toggle source
# File lib/redness/red_list.rb, line 52 def initialize(key) @key = key end
pop(key)
click to toggle source
# File lib/redness/red_list.rb, line 46 def self.pop(key) redis.execute_with_uncertainty(false) do redis.rpop(key) end end
redis()
click to toggle source
# File lib/redness/red_list.rb, line 4 def self.redis @redis ||= Red.new end
remove(key, value, occurrences = 0)
click to toggle source
# File lib/redness/red_list.rb, line 26 def self.remove(key, value, occurrences = 0) redis.execute_with_uncertainty(false) do redis.lrem(key, occurrences, value) end end
total_size(key)
click to toggle source
# File lib/redness/red_list.rb, line 36 def self.total_size(key) get(key).count end
trim_to(key, amount)
click to toggle source
# File lib/redness/red_list.rb, line 40 def self.trim_to(key, amount) redis.execute_with_uncertainty(false) do redis.ltrim(key, 0, (amount - 1)) end end
Public Instance Methods
add(value)
click to toggle source
# File lib/redness/red_list.rb, line 56 def add(value) self.class.add(@key, value) end
remove(value)
click to toggle source
# File lib/redness/red_list.rb, line 60 def remove(value) self.class.remove(@key, value) end
value()
click to toggle source
# File lib/redness/red_list.rb, line 64 def value self.class.get(@key) end