# File lib_core/rucy/cache.rb, line 23 def fetch(*args) # Double checked locking algorithm. # This algorithm would not work well if ruby thread is native. unless (obj = @cache_map[args]) then @cache_lock.synchronize{ unless (obj = @cache_map[args]) then obj = @factory.call(*args) if (@cache_limit && @cache_map.size >= @cache_limit) then # defence of cache overflow @cache_map.clear end @cache_map[args] = obj end } end obj end