Class: Redis::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/peek/views/redis.rb

Overview

Instrument Redis time

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.query_countObject

Returns the value of attribute query_count.



7
8
9
# File 'lib/peek/views/redis.rb', line 7

def query_count
  @query_count
end

.query_timeObject

Returns the value of attribute query_time.



7
8
9
# File 'lib/peek/views/redis.rb', line 7

def query_time
  @query_time
end

Instance Method Details

#call_with_timing(*args, &block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/peek/views/redis.rb', line 12

def call_with_timing(*args, &block)
  start = Time.now
  call_without_timing(*args, &block)
ensure
  duration = (Time.now - start)
  Redis::Client.query_time.update { |value| value + duration }
  Redis::Client.query_count.update { |value| value + 1 }
end