Module: SimpleCrud::CacheHelpers

Defined in:
lib/simple_crud/cache_helpers.rb

Overview

Default fetch_cached included into controllers that extend SimpleCrudController. Override in the controller to use a different store.

Instance Method Summary collapse

Instance Method Details

#expire_simple_crud_cache(action, path: request.fullpath) ⇒ Object



11
12
13
14
15
# File 'lib/simple_crud/cache_helpers.rb', line 11

def expire_simple_crud_cache(action, path: request.fullpath)
  Rails.cache.delete(
    SimpleCrud::ActionContext.cache_key_for(self.class.simple_crud_controller_model, action, path)
  )
end

#fetch_cached(key, ttl, &block) ⇒ Object



7
8
9
# File 'lib/simple_crud/cache_helpers.rb', line 7

def fetch_cached(key, ttl, &block)
  Rails.cache.fetch(key, expires_in: ttl, &block)
end