Class: Undo::Storage::RailsCache

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

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(cache = nil, options = {}) ⇒ RailsCache

Returns a new instance of RailsCache.



8
9
10
11
12
# File 'lib/undo/storage/rails_cache.rb', line 8

def initialize(cache = nil, options = {})
  @cache = cache
  @cache ||= Rails.cache if defined? Rails
  @options = options
end

Instance Method Details

#fetch(uuid) ⇒ Object



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

def fetch(uuid)
  deserialize cache.read uuid, options
end

#put(uuid, object) ⇒ Object



14
15
16
# File 'lib/undo/storage/rails_cache.rb', line 14

def put(uuid, object)
  cache.write uuid, serialize(object), options
end