Sha256: d8f6e63d9cfef9362522590f5508d28dc2f192f38a3d8a18e096380ce448bcda

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 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)
    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

15 entries across 15 versions & 1 rubygems

Version Path
rack-insight-0.5.28 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.27 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.26 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.25 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.24 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.23 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.22 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.21 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.20 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.19 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.18 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.17 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.16 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.15 lib/rack/insight/panels/cache_panel.rb
rack-insight-0.5.14 lib/rack/insight/panels/cache_panel.rb