class RecordCache::Statistics::Counter
Attributes
calls[RW]
hits[RW]
misses[RW]
Public Class Methods
new()
click to toggle source
# File lib/record_cache/statistics.rb, line 49 def initialize reset! end
Public Instance Methods
active?()
click to toggle source
# File lib/record_cache/statistics.rb, line 68 def active? RecordCache::Statistics.active? end
add(queried, found)
click to toggle source
add hit statatistics for the given cache strategy @param queried: nr of ids queried @param found: nr of records found in the cache
# File lib/record_cache/statistics.rb, line 56 def add(queried, found) @calls += 1 @hits += found @misses += (queried - found) end
inspect()
click to toggle source
# File lib/record_cache/statistics.rb, line 77 def inspect "#{percentage}% (#{@hits}/#{@hits + @misses})" end
percentage()
click to toggle source
# File lib/record_cache/statistics.rb, line 72 def percentage return 0.0 if @hits == 0 (@hits.to_f / (@hits + @misses)) * 100 end
reset!()
click to toggle source
# File lib/record_cache/statistics.rb, line 62 def reset! @hits = 0 @misses = 0 @calls = 0 end