Sha256: 57c4f11af769583ca04932c4c90706cadd12d084ed4981e14891a004209bb701

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 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 if !logger.debug? || Cacheflow.silenced?

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

if defined?(Dalli::Protocol::Binary)
  Dalli::Protocol::Binary.prepend(Cacheflow::Memcached::Notifications)
else
  Dalli::Server.prepend(Cacheflow::Memcached::Notifications)
end
Cacheflow::Memcached::Instrumenter.attach_to(:memcached)

Version data entries

1 entries across 1 versions & 1 rubygems

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