Module: Oboe::API::Memcache

Included in:
Inst::Dalli, Inst::MemCache, Inst::Memcached
Defined in:
lib/oboe/api/memcache.rb

Overview

Utility methods for the Memcache instrumentation

Constant Summary collapse

MEMCACHE_OPS =
%w(add append cas decr decrement delete fetch get incr increment prepend replace set)

Instance Method Summary collapse

Instance Method Details

#memcache_hit?(result) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/oboe/api/memcache.rb', line 11

def memcache_hit?(result)
  result.nil? ? 0 : 1
end

#remote_host(key) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/oboe/api/memcache.rb', line 15

def remote_host(key)
  return unless defined?(Lib.memcached_server_by_key) \
    && defined?(@struct) && defined?(is_unix_socket?)

  server_as_array = Lib.memcached_server_by_key(@struct, key.to_s)
  if server_as_array.is_a?(Array)
    server = server_as_array.first
    if is_unix_socket?(server)
      return 'localhost'
    elsif defined?(server.hostname)
      return server.hostname
    end
  end
end