Sha256: d1b7e917349b453735390859ba7f7722e0ff50ad1fa82816e5d20da52be75973
Contents?: true
Size: 928 Bytes
Versions: 5
Compression:
Stored size: 928 Bytes
Contents
require 'active_support/core_ext/array/extract_options' module Perforated module Compatibility def self.fetch_multi(*names, &block) if supports_fetch_multi? Perforated.cache.fetch_multi(*names, &block) else custom_fetch_multi(*names, &block) end end 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 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 end end
Version data entries
5 entries across 5 versions & 1 rubygems