class ActiveRedisStats::Base
Public Class Methods
all_key(offset: 0)
click to toggle source
rubocop:disable Lint/UnusedMethodArgument
# File lib/active_redis_stats/base.rb, line 85 def all_key(offset: 0) interval_key(:inf) end
all_keys(offset: 0)
click to toggle source
rubocop:enable Lint/UnusedMethodArgument
# File lib/active_redis_stats/base.rb, line 90 def all_keys(offset: 0) max = 9 + offset min = 0 + offset max.downto(min).collect do |num| interval_key(:all, time: num.years.ago(TIME)) end end
day_key(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 47 def day_key(offset: 0) interval_key(:month, time: offset.days.ago(TIME)) end
day_keys(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 51 def day_keys(offset: 0) boy = offset.days.ago(TIME).beginning_of_day 0.upto(23).collect do |num| interval_key(:day, time: num.hours.from_now(boy)) end end
expiration(key, seconds)
click to toggle source
# File lib/active_redis_stats/base.rb, line 99 def expiration(key, seconds) return if seconds.nil? ActiveRedisDB::Key .expire(primary_key(key), seconds) end
hour_key(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 33 def hour_key(offset: 0) interval_key(:day, time: offset.minutes.ago(TIME)) end
hour_keys(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 37 def hour_keys(offset: 0) adj = (30 * offset) max = 29 + adj min = 0 + adj max.downto(min).collect do |num| interval_key(:hour, time: num.minutes.ago(TIME)) end end
interval_key(format, time: TIME)
click to toggle source
# File lib/active_redis_stats/base.rb, line 25 def interval_key(format, time: TIME) format = format.to_sym return "#{format}:#{format}" if format == :inf interval = time.format(FORMATS[format]) "#{format}:#{interval}" end
month_key(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 59 def month_key(offset: 0) interval_key(:year, time: offset.months.ago(TIME)) end
month_keys(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 63 def month_keys(offset: 0) boy = offset.months.ago(TIME).beginning_of_month max = boy.end_of_month.day - 1 0.upto(max).collect do |num| interval_key(:month, time: num.days.from_now(boy)) end end
year_key(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 72 def year_key(offset: 0) interval_key(:all, time: offset.years.ago(TIME)) end
year_keys(offset: 0)
click to toggle source
# File lib/active_redis_stats/base.rb, line 76 def year_keys(offset: 0) boy = offset.years.ago(TIME).beginning_of_year 0.upto(11).collect do |num| interval_key(:year, time: num.months.from_now(boy)) end end