Sha256: b8da2de2d05ac01dc34e6dfcb0cdfe8078865bbae60cdfa283a43409b23a369a

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

module Cacheflow
  module Memcached
    module Notifications
      def request(op, *args)
        payload = {
          op: op,
          args: args
        }
        ActiveSupport::Notifications.instrument("query.memcached", payload) do
          super
        end
      end
    end

    class Instrumenter < ActiveSupport::LogSubscriber
      def query(event)
        return unless logger.debug?

        name = "%s (%.2fms)" % ["Memcached", event.duration]
        debug "  #{color(name, BLUE, true)} #{event.payload[:op].to_s.upcase} #{event.payload[:args].join(" ")}"
      end
    end
  end
end

Dalli::Server.prepend(Cacheflow::Memcached::Notifications)
Cacheflow::Memcached::Instrumenter.attach_to(:memcached)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cacheflow-0.1.0 lib/cacheflow/memcached.rb