lib/roda/cache.rb in roda-3.39.0 vs lib/roda/cache.rb in roda-3.40.0
- old
+ new
@@ -20,9 +20,16 @@
# Make setting value in underlying hash thread safe.
def []=(key, value)
@mutex.synchronize{@hash[key] = value}
end
+ # Return the frozen internal hash. The internal hash can then
+ # be accessed directly since it is frozen and there are no
+ # thread safety issues.
+ def freeze
+ @hash.freeze
+ end
+
private
# Create a copy of the cache with a separate mutex.
def initialize_copy(other)
@mutex = Mutex.new