module TwitterFriendly::CachingAndLogging
Public Instance Methods
caching(*method_names)
click to toggle source
TODO 1つのメソッドに対して1回しか実行されないようにする 全体をキャッシュさせ、さらにロギングを行う
Calls superclass method
# File lib/twitter_friendly/caching_and_logging.rb, line 8 def caching(*method_names) method_names.each do |method_name| define_method(method_name) do |*args| options = args.dup.extract_options! Instrumenter.start_processing(method_name, options) Instrumenter.complete_processing(method_name, options) do key = CacheKey.gen(method_name, args, hash: credentials_hash) @cache.fetch(key, args: [method_name, options]) do Instrumenter.perform_request(method_name, options) {super(*args)} end end end end end
logging(*root_args)
click to toggle source
全体をキャッシュせずにロギングだけを行う
Calls superclass method
# File lib/twitter_friendly/caching_and_logging.rb, line 27 def logging(*root_args) root_args.each do |method_name| define_method(method_name) do |*args| options = args.dup.extract_options! Instrumenter.start_processing(method_name, options) Instrumenter.complete_processing(method_name, options) {super(*args)} end end end