lib/redis/list.rb in redis-objects-0.2.1 vs lib/redis/list.rb in redis-objects-0.2.2
- old
+ new
@@ -4,12 +4,14 @@
# behave as much like Ruby arrays as possible.
#
class List
require 'enumerator'
include Enumerable
- require 'redis/serialize'
- include Redis::Serialize
+ require 'redis/helpers/core_commands'
+ include Redis::Helpers::CoreCommands
+ require 'redis/helpers/serialize'
+ include Redis::Helpers::Serialize
attr_reader :key, :options, :redis
def initialize(key, redis=$redis, options={})
@key = key
@redis = redis
@@ -61,10 +63,11 @@
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.
# Redis: LREM
def delete(name, count=0)
redis.lrem(key, count, name) # weird api
end
@@ -92,14 +95,9 @@
end
# Return the last element in the list. Redis: LINDEX(-1)
def last
at(-1)
- end
-
- # Clear the list entirely. Redis: DEL
- def clear
- redis.del(key)
end
# Return the length of the list. Aliased as size. Redis: LLEN
def length
redis.llen(key)
\ No newline at end of file