Class: RSX::Cache::Rails

Inherits:
Object
  • Object
show all
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

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

#clearObject



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)

#storeObject



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)