Class: RSX::Cache::Rails
- Inherits:
-
Object
- Object
- RSX::Cache::Rails
- Defined in:
- lib/rsx/cache.rb
Overview
Stores fragments in Rails.cache so they live alongside the rest of the application's cache and are invalidated by the same tooling.
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #fetch(key, expires_in: nil, &block) ⇒ Object
-
#initialize(store = nil) ⇒ Rails
constructor
A new instance of Rails.
- #read(key) ⇒ Object
- #store ⇒ Object
- #write(key, value, expires_in: nil) ⇒ Object
Constructor Details
#initialize(store = nil) ⇒ Rails
Returns a new instance of Rails.
75 76 77 |
# File 'lib/rsx/cache.rb', line 75 def initialize(store = nil) @store = store end |
Instance Method Details
#clear ⇒ Object
90 |
# File 'lib/rsx/cache.rb', line 90 def clear = store.clear |
#delete(key) ⇒ Object
89 |
# File 'lib/rsx/cache.rb', line 89 def delete(key) = store.delete(key) |
#fetch(key, expires_in: nil, &block) ⇒ Object
83 84 85 |
# File 'lib/rsx/cache.rb', line 83 def fetch(key, expires_in: nil, &block) store.fetch(key, expires_in: expires_in, &block) end |
#read(key) ⇒ Object
87 |
# File 'lib/rsx/cache.rb', line 87 def read(key) = store.read(key) |
#store ⇒ Object
79 80 81 |
# File 'lib/rsx/cache.rb', line 79 def store @store || ::Rails.cache end |
#write(key, value, expires_in: nil) ⇒ Object
88 |
# File 'lib/rsx/cache.rb', line 88 def write(key, value, expires_in: nil) = store.write(key, value, expires_in: expires_in) |