module MethodCachable
Constants
- VERSION
Public Instance Methods
cache_list_key()
click to toggle source
# File lib/method_cachable.rb, line 17 def cache_list_key "cache_list_key:#{self.class.name}:#{self.id}" end
clear_cache()
click to toggle source
# File lib/method_cachable.rb, line 11 def clear_cache flush_cache cache_list_key flush_cache "cache_list_key:#{self.class.name}" flush_cache "cache_list_key:#{self.class.superclass.name}" end
flush_cache(saving_key)
click to toggle source
# File lib/method_cachable.rb, line 63 def flush_cache(saving_key) lst = Rails.cache.fetch saving_key do; [] end lst.each {|key| flush_key(key) } end
flush_key(key)
click to toggle source
# File lib/method_cachable.rb, line 68 def flush_key(key) Rails.cache.delete key end
with_env(key, saving_key = nil) { || ... }
click to toggle source
# File lib/method_cachable.rb, line 50 def with_env(key, saving_key = nil, &block) if Rails.env.production? unless saving_key.nil? lst = Rails.cache.fetch saving_key do; [] end lst << key unless lst.include?(saving_key) Rails.cache.write saving_key, lst, expires_in: 24.hours end Rails.cache.fetch key, expires_in: 2.hours, &block else yield end end