Module: RailsNamedCache::RailsExt
- Defined in:
- lib/rails_named_cache/rails_ext.rb
Overview
Prepended onto the Rails singleton class so Rails.cache takes an
optional store name.
This is the only monkey patch in the gem.
Rails.cache # => the default Rails cache, untouched
Rails.cache(:memory) # => the store registered as :memory
Instance Method Summary collapse
-
#cache(*name) ⇒ ActiveSupport::Cache::Store
Splat rather than a
nildefault, soRails.cache(name)with anilname raises instead of quietly reading the default store.
Instance Method Details
#cache(*name) ⇒ ActiveSupport::Cache::Store
Splat rather than a nil default, so Rails.cache(name) with a nil
name raises instead of quietly reading the default store.
19 20 21 22 23 |
# File 'lib/rails_named_cache/rails_ext.rb', line 19 def cache(*name) return super() if name.empty? RailsNamedCache.fetch(*name) end |