class Rudis::List
Public Instance Methods
[](thing)
click to toggle source
# File lib/rudis/structures/list.rb, line 29 def [](thing) if thing.is_a? Fixnum index thing elsif thing.is_a? Range range thing end end
all()
click to toggle source
# File lib/rudis/structures/list.rb, line 24 def all range 0..-1 end
Also aliased as: to_a
empty?()
click to toggle source
# File lib/rudis/structures/list.rb, line 10 def empty? len == 0 end
index(i)
click to toggle source
# File lib/rudis/structures/list.rb, line 14 def index(i) type.get(redis.lindex(key, i.to_i)) end
len()
click to toggle source
# File lib/rudis/structures/list.rb, line 3 def len redis.llen(key) end
lpop()
click to toggle source
# File lib/rudis/structures/list.rb, line 60 def lpop e = redis.lpop(key) e && type.get(e) end
Also aliased as: shift
lpush(val)
click to toggle source
# File lib/rudis/structures/list.rb, line 54 def lpush(val) redis.lpush(key, type.put(val)) end
range(range)
click to toggle source
# File lib/rudis/structures/list.rb, line 18 def range(range) redis.lrange(key, range.first.to_i, range.last.to_i).map do |e| type.get(e) end end
rpop()
click to toggle source
# File lib/rudis/structures/list.rb, line 48 def rpop e = redis.rpop(key) e && type.get(e) end
Also aliased as: pop
rpush(val)
click to toggle source
# File lib/rudis/structures/list.rb, line 42 def rpush(val) redis.rpush(key, type.put(val)) end
set(i, val)
click to toggle source
# File lib/rudis/structures/list.rb, line 37 def set(i, val) redis.lset(key, i.to_i, type.put(val)) end
Also aliased as: []=
trim(range)
click to toggle source
# File lib/rudis/structures/list.rb, line 66 def trim(range) redis.trim(key, range.first.to_i, range.last.to_i) end
Also aliased as: trim!