module Caching::InstanceMethods

Public Instance Methods

cache_storage() click to toggle source
# File lib/caching.rb, line 25
def cache_storage
  @cache_storage ||= Storage.new
end
cached_methods_keys() click to toggle source
# File lib/caching.rb, line 29
def cached_methods_keys
  @cached_methods_keys ||= Hash.new {|h,k| h[k] = Set.new}
end
clear_cache(*methods) click to toggle source
# File lib/caching.rb, line 33
def clear_cache(*methods)
  method_keys = cached_methods_keys.
    select{ |m,_| methods.include? m }.
    flat_map{ |_,keys| keys.to_a }
  cache_storage.clear *method_keys
  method_keys.each { |k| cached_methods_keys.delete k }
end