class Familia::List
Public Instance Methods
<<(v)
click to toggle source
# File lib/familia/redisobject.rb, line 361 def << v push v end
Also aliased as: add
[](idx, count=nil)
click to toggle source
# File lib/familia/redisobject.rb, line 382 def [] idx, count=nil if idx.is_a? Range range idx.first, idx.last elsif count case count <=> 0 when 1 then range(idx, idx + count - 1) when 0 then [] when -1 then nil end else at idx end end
Also aliased as: slice
at(idx)
click to toggle source
# File lib/familia/redisobject.rb, line 462 def at idx from_redis redis.lindex(rediskey, idx) end
collect(&blk)
click to toggle source
# File lib/familia/redisobject.rb, line 446 def collect &blk range.collect &blk end
collectraw(&blk)
click to toggle source
# File lib/familia/redisobject.rb, line 454 def collectraw &blk rangeraw.collect &blk end
delete(v, count=0)
click to toggle source
# File lib/familia/redisobject.rb, line 397 def delete v, count=0 redis.lrem rediskey, count, to_redis(v) end
each(&blk)
click to toggle source
def revmembers count=1 #TODO
range -count, 0
end
# File lib/familia/redisobject.rb, line 430 def each &blk range.each &blk end
each_with_index(&blk)
click to toggle source
# File lib/familia/redisobject.rb, line 434 def each_with_index &blk range.each_with_index &blk end
eachraw(&blk)
click to toggle source
# File lib/familia/redisobject.rb, line 438 def eachraw &blk rangeraw.each &blk end
eachraw_with_index(&blk)
click to toggle source
# File lib/familia/redisobject.rb, line 442 def eachraw_with_index &blk rangeraw.each_with_index &blk end
empty?()
click to toggle source
# File lib/familia/redisobject.rb, line 349 def empty? size == 0 end
first()
click to toggle source
# File lib/familia/redisobject.rb, line 466 def first at 0 end
last()
click to toggle source
# File lib/familia/redisobject.rb, line 470 def last at -1 end
members(count=-1)
click to toggle source
# File lib/familia/redisobject.rb, line 413 def members count=-1 echo :members, caller[0] if Familia.debug count -= 1 if count > 0 range 0, count end
membersraw(count=-1)
click to toggle source
# File lib/familia/redisobject.rb, line 421 def membersraw count=-1 count -= 1 if count > 0 rangeraw 0, count end
pop()
click to toggle source
# File lib/familia/redisobject.rb, line 374 def pop from_redis redis.rpop(rediskey) end
push(*values)
click to toggle source
# File lib/familia/redisobject.rb, line 353 def push *values echo :push, caller[0] if Familia.debug values.flatten.compact.each { |v| redis.rpush rediskey, to_redis(v) } redis.ltrim rediskey, -@opts[:maxlength], -1 if @opts[:maxlength] update_expiration self end
range(sidx=0, eidx=-1)
click to toggle source
# File lib/familia/redisobject.rb, line 404 def range sidx=0, eidx=-1 el = rangeraw sidx, eidx multi_from_redis *el end
rangeraw(sidx=0, eidx=-1)
click to toggle source
# File lib/familia/redisobject.rb, line 409 def rangeraw sidx=0, eidx=-1 redis.lrange(rediskey, sidx, eidx) end
select(&blk)
click to toggle source
# File lib/familia/redisobject.rb, line 450 def select &blk range.select &blk end
selectraw(&blk)
click to toggle source
# File lib/familia/redisobject.rb, line 458 def selectraw &blk rangeraw.select &blk end
shift()
click to toggle source
# File lib/familia/redisobject.rb, line 378 def shift from_redis redis.lpop(rediskey) end
size()
click to toggle source
# File lib/familia/redisobject.rb, line 344 def size redis.llen rediskey end
Also aliased as: length
unshift(*values)
click to toggle source
# File lib/familia/redisobject.rb, line 366 def unshift *values values.flatten.compact.each { |v| redis.lpush rediskey, to_redis(v) } # TODO: test maxlength redis.ltrim rediskey, 0, @opts[:maxlength] - 1 if @opts[:maxlength] update_expiration self end