lib/redis/list.rb in redis-objects-1.1.0 vs lib/redis/list.rb in redis-objects-1.2.0

- old
+ new

@@ -19,17 +19,21 @@ self # for << 'a' << 'b' end # Add a member before or after pivot in the list. Redis: LINSERT def insert(where,pivot,value) - redis.linsert(key,where,marshal(pivot),marshal(value)) + allow_expiration do + redis.linsert(key,where,marshal(pivot),marshal(value)) + end end # Add a member to the end of the list. Redis: RPUSH def push(*values) - redis.rpush(key, values.map{|v| marshal(v) }) - redis.ltrim(key, -options[:maxlength], -1) if options[:maxlength] + allow_expiration do + redis.rpush(key, values.map{|v| marshal(v) }) + redis.ltrim(key, -options[:maxlength], -1) if options[:maxlength] + end end # Remove a member from the end of the list. Redis: RPOP def pop unmarshal redis.rpop(key) @@ -47,12 +51,14 @@ unmarshal redis.rpoplpush(key, destination.is_a?(Redis::List) ? destination.key : destination.to_s) end # Add a member to the start of the list. Redis: LPUSH def unshift(*values) - redis.lpush(key, values.map{|v| marshal(v) }) - redis.ltrim(key, 0, options[:maxlength] - 1) if options[:maxlength] + allow_expiration do + redis.lpush(key, values.map{|v| marshal(v) }) + redis.ltrim(key, 0, options[:maxlength] - 1) if options[:maxlength] + end end # Remove a member from the start of the list. Redis: LPOP def shift unmarshal redis.lpop(key) @@ -83,11 +89,13 @@ end alias_method :slice, :[] # Same functionality as Ruby arrays. def []=(index, value) - redis.lset(key, index, marshal(value)) + allow_expiration do + redis.lset(key, index, marshal(value)) + end end # Delete the element(s) from the list that match name. If count is specified, # only the first-N (if positive) or last-N (if negative) will be removed. # Use .del to completely delete the entire key. @@ -140,9 +148,7 @@ end def to_s values.join(', ') end - - expiration_filter :[]=, :push, :<<, :insert, :unshift end end