ConcurrentCacheBackend
# File lib/thread_safe/cache.rb, line 34 def [](key) if value = super value elsif @default_proc && !key?(key) @default_proc.call(self, key) else value end end
# File lib/thread_safe/cache.rb, line 87 def each_key each_pair {|k, v| yield k} end
# File lib/thread_safe/cache.rb, line 91 def each_value each_pair {|k, v| yield v} end
# File lib/thread_safe/cache.rb, line 95 def empty? each_pair {|k, v| return false} true end
# File lib/thread_safe/cache.rb, line 47 def fetch(key, default_value = NULL) if NULL != (value = get_or_default(key, NULL)) value elsif block_given? yield key elsif NULL != default_value default_value else raise KEY_ERROR, 'key not found' end end
# File lib/thread_safe/cache.rb, line 75 def keys arr = [] each_pair {|k, v| arr << k} arr end
# File lib/thread_safe/cache.rb, line 106 def marshal_dump raise TypeError, "can't dump hash with default proc" if @default_proc h = {} each_pair {|k, v| h[k] = v} h end
# File lib/thread_safe/cache.rb, line 113 def marshal_load(hash) initialize populate_from(hash) end
# File lib/thread_safe/cache.rb, line 59 def put_if_absent(key, value) computed = false result = compute_if_absent(key) do computed = true value end computed ? nil : result end
# File lib/thread_safe/cache.rb, line 100 def size count = 0 each_pair {|k, v| count += 1} count end
Generated with the Darkfish Rdoc Generator 2.