Mustermann::EqualityMap

Parsed documentation:
View on GitHub
A simple wrapper around ObjectSpace::WeakMap that allows matching keys by equality rather than identity.
Used for caching. Note that `fetch` is not guaranteed to return the object, even if it has not been
garbage collected yet, especially when used concurrently. Therefore, the block passed to `fetch` has to
be idempotent.

@example
  class ExpensiveComputation
    @map = Mustermann::EqualityMap.new

    def self.new(*args)
      @map.fetch(*args) { super }
    end
  end

@see #fetch
No suggestions.
Please help! Open an issue on GitHub if this assessment is incorrect.