module Perforated::Compatibility
Public Class Methods
custom_fetch_multi(*names) { |name| ... }
click to toggle source
# File lib/perforated/compatibility/fetch_multi.rb, line 13 def self.custom_fetch_multi(*names) options = names.extract_options! results = Perforated.cache.read_multi(*names, options) names.each_with_object({}) do |(name, _), memo| memo[name] = results.fetch(name) do value = yield name Perforated.cache.write(name, value, options) value end end end
fetch_multi(*names, &block)
click to toggle source
# File lib/perforated/compatibility/fetch_multi.rb, line 5 def self.fetch_multi(*names, &block) if supports_fetch_multi? Perforated.cache.fetch_multi(*names, &block) else custom_fetch_multi(*names, &block) end end
supports_fetch_multi?()
click to toggle source
# File lib/perforated/compatibility/fetch_multi.rb, line 26 def self.supports_fetch_multi? cache = Perforated.cache cache.respond_to?(:fetch_multi) && !( cache.instance_of?(ActiveSupport::Cache::MemoryStore) || cache.instance_of?(ActiveSupport::Cache::NullStore) ) end