Sha256: 31e057ca930f3f103eae99f856365e2bed7470a4822554609b089dbf6f769e4a

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module Rack::Insight

  class CachePanel < Panel
    require "rack/insight/panels/cache_panel/panel_app"
    require "rack/insight/panels/cache_panel/stats"

    def request_start(env, start)
      @stats = Stats.new
    end

    def request_finish(env, st, hd, bd, timing)
      store(env, @stats)
    end

    def after_detect(method_call, timing, args, result)
      method, key = method_call.method, args.first
      if(defined? Dalli and Dalli::Client === method_call.object)
        method, key = args[0], args[1]
      end
      logger.info{ "Cache panel got #{method} #{key.inspect}" } if verbose(:high)
      @stats.record_call(method, timing.duration, !result.nil?, key) if method.present?
    end

    def panel_app
      PanelApp.new
    end

    def heading_for_request(number)
      stats = retrieve(number).first

      "Cache: %.2fms (#{stats.queries.size} calls)" % stats.time
    end

    def content_for_request(number)
      stats = retrieve(number).first
      render_template "panels/cache", :stats => stats
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.6.3 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.6.2 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.30 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.29 lib/rack/insight/panels/cache_panel.rb