module Dry::Core::Cache

def self.extended(klass)

Other tags:
    Api: - private
def self.extended(klass)
  super
  klass.include(Methods)
  klass.instance_variable_set(:@__cache__, ::Concurrent::Map.new)
end

def cache

Other tags:
    Api: - private
def cache
  @__cache__
end

def fetch_or_store(*args, &)

Returns:
  • (Object) - block's return value (cached for subsequent calls with

Other tags:
    Note: - beware Proc instance hashes are not equal, i.e. -> { 1 }.hash != -> { 1 }.hash,

Other tags:
    Yield: - An arbitrary block

Parameters:
  • args (Array) -- List of hashable objects
    def fetch_or_store(*args, &)
      cache.fetch_or_store(args.hash, &)
    end

    def inherited(klass)

    Other tags:
      Api: - private
    def inherited(klass)
      super
      klass.instance_variable_set(:@__cache__, cache)
    end