class Docket::Storage::Redis
Public Class Methods
new(options={})
click to toggle source
Calls superclass method
Docket::Storage::Base::new
# File lib/docket/storage/redis.rb, line 8 def initialize options={} super self.db = options[:redis] || ::Redis.new end
Public Instance Methods
append(key, value)
click to toggle source
# File lib/docket/storage/redis.rb, line 17 def append key, value if read(key).nil? save(key, Array(value)) else current = read(key) new_value = Array(current) << value save(key, new_value.uniq) end end
clear!()
click to toggle source
# File lib/docket/storage/redis.rb, line 35 def clear! keys = keys_context redis.del(*keys) unless keys.empty? end
describe()
click to toggle source
# File lib/docket/storage/redis.rb, line 40 def describe keys_context.map do |key| [key, read(clean(key))] end end
read(key)
click to toggle source
# File lib/docket/storage/redis.rb, line 31 def read key read_packed key end
remove(key)
click to toggle source
# File lib/docket/storage/redis.rb, line 27 def remove key redis.del(namespaced(key)) end
save(key, value, options={})
click to toggle source
# File lib/docket/storage/redis.rb, line 13 def save key, value, options={} save_packed key, value end
Private Instance Methods
keys_context()
click to toggle source
# File lib/docket/storage/redis.rb, line 48 def keys_context redis.keys "#{namespace}:*" end
read_packed(key)
click to toggle source
# File lib/docket/storage/redis.rb, line 56 def read_packed key value = redis.get(namespaced(key)) if value MessagePack.unpack(value) else nil end end
redis()
click to toggle source
# File lib/docket/storage/redis.rb, line 65 def redis self.db end
save_packed(key, value)
click to toggle source
# File lib/docket/storage/redis.rb, line 52 def save_packed key, value redis.set(namespaced(key), MessagePack.pack(value)) end