Class: SimpleApm::RedisKey

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

Class Method Summary collapse

Class Method Details

.[](key, _date = nil) ⇒ Object



103
104
105
# File 'lib/simple_apm/redis.rb', line 103

def [](key, _date = nil)
  "#{_date||query_date}:#{key}"
end

.query_dateObject



99
100
101
# File 'lib/simple_apm/redis.rb', line 99

def query_date
  Thread.current['apm_query_date'] || Time.now.strftime('%Y-%m-%d')
end

.query_date=(d = nil) ⇒ Object



95
96
97
# File 'lib/simple_apm/redis.rb', line 95

def query_date=(d = nil)
  Thread.current['apm_query_date'] = d
end

.set_query_date(d = nil) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/simple_apm/redis.rb', line 83

def set_query_date(d = nil)
  if block_given?
    _ = query_date
    Thread.current['apm_query_date'] = d
    res = yield
    Thread.current['apm_query_date'] = _
    res
  else
    Thread.current['apm_query_date'] = d
  end
end