Skip to content

Commit

Permalink
Merge pull request #440 from mensfeld/main
Browse files Browse the repository at this point in the history
Make the yaml cache fully thread-safe
  • Loading branch information
flash-gordon authored Nov 23, 2022
2 parents 2ecffb6 + 0b11bb3 commit 269362e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/dry/schema/messages/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def self.flat_hash(hash, path = EMPTY_ARRAY, keys = {})

# @api private
def self.cache
@cache ||= Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new }
@cache ||= Concurrent::Map.new do |h, k|
h.compute_if_absent(k) { Concurrent::Map.new }
end
end

# @api private
Expand Down

0 comments on commit 269362e

Please sign in to comment.