class RedisClusterCacheBenchmark::LoggingClient

Constants

MEGA

Public Class Methods

new(impl, logger) click to toggle source
# File lib/redis_cluster_cache_benchmark/logging_client.rb, line 5
def initialize(impl, logger)
  @impl = impl
  @logger = logger
end

Public Instance Methods

get(key) click to toggle source
# File lib/redis_cluster_cache_benchmark/logging_client.rb, line 10
def get(key)
  __logging__("[GET]"){ @impl.get(key) }
end
set(key, value, options = {}) click to toggle source
# File lib/redis_cluster_cache_benchmark/logging_client.rb, line 14
def set(key, value, options = {})
  __logging__("[SET]"){ @impl.set(key, value, options) }
end

Private Instance Methods

__logging__(msg = nil) { || ... } click to toggle source
# File lib/redis_cluster_cache_benchmark/logging_client.rb, line 22
def __logging__(msg = nil)
  t0 = Time.now.to_f
  begin
    return yield
  ensure
    @logger.info("%s %6.9f microsec" % [msg, (Time.now.to_f - t0) * MEGA])
  end
end