lib/redis/list.rb in redis-objects-1.4.0 vs lib/redis/list.rb in redis-objects-1.4.2

- old
+ new

@@ -27,12 +27,13 @@ end # Add a member to the end of the list. Redis: RPUSH def push(*values) allow_expiration do - redis.rpush(key, values.map{|v| marshal(v) }) + count = redis.rpush(key, values.map{|v| marshal(v) }) redis.ltrim(key, -options[:maxlength], -1) if options[:maxlength] + count end end # Remove a member from the end of the list. Redis: RPOP def pop(n=nil) @@ -60,11 +61,12 @@ end # Add a member to the start of the list. Redis: LPUSH def unshift(*values) allow_expiration do - redis.lpush(key, values.map{|v| marshal(v) }) + count = redis.lpush(key, values.map{|v| marshal(v) }) redis.ltrim(key, 0, options[:maxlength] - 1) if options[:maxlength] + count end end # Remove a member from the start of the list. Redis: LPOP def shift(n=nil)