Module: Rails

Defined in:
lib/multi_cache/rails.rb,
lib/multi_cache/rails/application/configuration.rb,
lib/multi_cache/rails/application/multi_cache_bootstrap.rb

Defined Under Namespace

Classes: Application

Class Method Summary collapse

Class Method Details

.cache(name = :default) ⇒ Object



16
17
18
19
20
# File 'lib/multi_cache/rails.rb', line 16

def cache(name = :default)
  return nil unless defined? @cache
  return RAILS_CACHE if name == :default
  @cache[name]
end

.cache=(cache_obj) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/multi_cache/rails.rb', line 3

def cache=(cache_obj)
  @cache = {} unless defined? @cache
  case cache_obj
  when Hash
    key = cache_obj[:name]
    @cache[key] = cache_obj[:cache]
  else
    @cache[:default] = cache_obj
    silence_warnings { Object.const_set 'RAILS_CACHE', cache_obj }
  end
  nil
end