Sha256: 6661d613af24819e9c5972f6625d3720d8c9c75ab9b23f9a1b5b34f3f3139293

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 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} #{Cacheflow.args(event.payload[:args])}"
      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

2 entries across 2 versions & 1 rubygems

Version Path
cacheflow-0.4.0 lib/cacheflow/memcached.rb
cacheflow-0.3.3 lib/cacheflow/memcached.rb