Class: Undo::Storage::Redis

Inherits:
Adapter
  • Object
show all
Defined in:
lib/undo/storage/redis.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis, options = {}) ⇒ Redis

Returns a new instance of Redis.



7
8
9
10
# File 'lib/undo/storage/redis.rb', line 7

def initialize(redis, options = {})
  @redis = redis
  super options
end

Instance Method Details

#delete(uuid, options = {}) ⇒ Object



23
24
25
# File 'lib/undo/storage/redis.rb', line 23

def delete(uuid, options = {})
  redis.del uuid
end

#fetch(uuid, options = {}) ⇒ Object



18
19
20
21
# File 'lib/undo/storage/redis.rb', line 18

def fetch(uuid, options = {})
  data = redis.get(uuid) or raise KeyError, "key #{uuid} not found"
  unpack data
end

#store(uuid, object, options = {}) ⇒ Object



12
13
14
15
16
# File 'lib/undo/storage/redis.rb', line 12

def store(uuid, object, options = {})
  redis.set uuid,
            pack(object),
            adapter_options(options)
end