class MerryGoRound::Entry
Public Class Methods
new(key, increment = 1, timestamp = Time.now)
click to toggle source
# File lib/merry_go_round/entry.rb, line 3 def initialize(key, increment = 1, timestamp = Time.now) @key = key @increment = increment # Note, storing in the past isn't supported. If you set this to something the # aggregator has already run, the results are undefined. @timestamp = timestamp end
Public Instance Methods
record!()
click to toggle source
# File lib/merry_go_round/entry.rb, line 12 def record! # Normalize time. Drop seconds and convert to UTC time = Time.at(@timestamp.to_i - @timestamp.sec).utc.to_i # Store in Redis redis.hincrby "entry-#{time.to_s}", @key, @increment end
Private Instance Methods
redis()
click to toggle source
# File lib/merry_go_round/entry.rb, line 22 def redis MerryGoRound.redis end