Class: ActiveSupport::Cache::Level2

Inherits:
Store
  • Object
show all
Defined in:
lib/active_support/cache/level2.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store_options) ⇒ Level2



14
15
16
17
18
19
# File 'lib/active_support/cache/level2.rb', line 14

def initialize(store_options)
  @stores = store_options.each_with_object({}) do |(name,options), h|
    h[name] = ActiveSupport::Cache.lookup_store(options)
  end
  @options = {}
end

Instance Attribute Details

#storesObject (readonly)

Returns the value of attribute stores.



12
13
14
# File 'lib/active_support/cache/level2.rb', line 12

def stores
  @stores
end

Class Method Details

.instrumentObject

Rails 3 doesn’t instrument by default, this overrides it



40
41
42
# File 'lib/active_support/cache/level2.rb', line 40

def self.instrument
  true
end

Instance Method Details

#cleanup(*args) ⇒ Object



21
22
23
# File 'lib/active_support/cache/level2.rb', line 21

def cleanup(*args)
  @stores.each_value { |s| s.cleanup(*args) }
end

#clear(*args) ⇒ Object



25
26
27
# File 'lib/active_support/cache/level2.rb', line 25

def clear(*args)
  @stores.each_value { |s| s.clear(*args) }
end

#read_multi(*names) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/active_support/cache/level2.rb', line 29

def read_multi(*names)
  result = {}
  @stores.each do |_name,store|
    data = store.read_multi(*names)
    result.merge! data
    names -= data.keys
  end
  result
end