Class: Rails::Cache::Debugger::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/cache/debugger/subscriber.rb

Instance Method Summary collapse

Instance Method Details

#call(name, start, finish, _id, payload) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rails/cache/debugger/subscriber.rb', line 7

def call(name, start, finish, _id, payload)
  return unless configuration.enabled
  return unless configuration.log_events.include?(name)

  key = payload[:key]
  duration = ((finish - start) * 1000).round(2)

  case name
  when "cache_read.active_support"
    hit = payload[:hit]
    Debugger.log "#{hit ? 'HIT' : 'MISS'} key: #{key} (#{duration}ms)"
  when "cache_write.active_support"
    Debugger.log "WRITE key: #{key} (#{duration}ms)"
  when "cache_fetch_hit.active_support"
    Debugger.log "FETCH_HIT key: #{key} (#{duration}ms)"
  end
end