Method: ActiveSupport::Cache::Store#read_multi

Defined in:
lib/active_support/cache.rb

#read_multi(*names) ⇒ Object

Reads multiple values at once from the cache. Options can be passed in the last argument.

Some cache implementation may optimize this method.

Returns a hash mapping the names provided to the values found.



544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/active_support/cache.rb', line 544

def read_multi(*names)
  return {} if names.empty?

  options = names.extract_options!
  options = merged_options(options)
  keys    = names.map { |name| normalize_key(name, options) }

  instrument_multi :read_multi, keys, options do |payload|
    read_multi_entries(names, **options, event: payload).tap do |results|
      payload[:hits] = results.keys.map { |name| normalize_key(name, options) }
    end
  end
end