Module: MoreCoreExtensions::CacheWithTimeout::ClassMethods

Defined in:
lib/more_core_extensions/core_ext/module/cache_with_timeout.rb

Instance Method Summary collapse

Instance Method Details

#clear_all_cache_with_timeoutObject

Globally clears all cached values across all classes. This is

mostly useful for testing to avoid test contamination.

Example:

RSpec.configure do |c|
  c.after { Module.clear_all_cache_with_timeout }
end


91
92
93
94
95
# File 'lib/more_core_extensions/core_ext/module/cache_with_timeout.rb', line 91

def clear_all_cache_with_timeout
  $cache_with_timeout_lock.synchronize(:EX) do
    $cache_with_timeout.each_value(&:clear)
  end
end