Sha256: 8b6a5fb0987d6ced682a43cfb81bc3b3a12fef02266f4754f8af0a0b83636dce

Contents?: true

Size: 857 Bytes

Versions: 3

Compression:

Stored size: 857 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, 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

3 entries across 3 versions & 1 rubygems

Version Path
cacheflow-0.3.1 lib/cacheflow/memcached.rb
cacheflow-0.3.0 lib/cacheflow/memcached.rb
cacheflow-0.2.1 lib/cacheflow/memcached.rb