Class: Elephas::Backends::RubyOnRails
- Defined in:
- lib/elephas/backends/ruby_on_rails.rb
Overview
This is a Ruby on Rails backend, which uses Rails.cache.
Instance Method Summary collapse
-
#delete(key) ⇒ Boolean
Deletes a value from the cache.
-
#exists?(key) ⇒ Boolean
Checks if a key exists in the cache.
-
#read(key) ⇒ Entry|NilClass
Reads a value from the cache.
-
#write(key, value, options = {}) ⇒ Object
Writes a value to the cache.
Methods inherited from Base
Instance Method Details
#delete(key) ⇒ Boolean
Deletes a value from the cache.
37 38 39 40 41 |
# File 'lib/elephas/backends/ruby_on_rails.rb', line 37 def delete(key) rv = Rails.cache.exist?(key) Rails.cache.delete(key) rv end |
#exists?(key) ⇒ Boolean
Checks if a key exists in the cache.
47 48 49 |
# File 'lib/elephas/backends/ruby_on_rails.rb', line 47 def exists?(key) Rails.cache.exist?(key) && Rails.cache.read(key).valid?(self) end |
#read(key) ⇒ Entry|NilClass
Reads a value from the cache.
15 16 17 |
# File 'lib/elephas/backends/ruby_on_rails.rb', line 15 def read(key) exists?(key) ? Rails.cache.read(key) : nil end |