Module: ActsAsCached::Benchmarking

Defined in:
lib/acts_as_cached/benchmarking.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.benchmark(event) ⇒ Object



18
19
20
21
22
23
# File 'lib/acts_as_cached/benchmarking.rb', line 18

def self.benchmark(event)
  self.runtime += event.duration
  return unless Rails.logger && Rails.logger.debug?

  Rails.logger.debug("Cache #{event.name.sub('cache_','').sub('.active_support','')} ==> #{event.payload[:key]} (#{'%.1fms' % event.duration}) #{'HIT' if event.payload[:hit]}#{'MISS' if event.payload[:miss]}")
end

.reset_runtimeObject



13
14
15
16
# File 'lib/acts_as_cached/benchmarking.rb', line 13

def self.reset_runtime
  rt, self.runtime = runtime, 0
  rt
end

.runtimeObject



9
10
11
# File 'lib/acts_as_cached/benchmarking.rb', line 9

def self.runtime
  Thread.current['memcache_runtime'] ||= 0.0
end

.runtime=(value) ⇒ Object



5
6
7
# File 'lib/acts_as_cached/benchmarking.rb', line 5

def self.runtime=(value)
  Thread.current['memcache_runtime'] = value
end