1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Add TTL for stats keys

This change adds a 5 years TTL on redis keys containing daily stats. See #3905 for more details
This commit is contained in:
Óscar de Arriba 2018-08-06 19:46:00 +02:00 committed by Mike Perham
parent e339d23036
commit 03e63b8c99

View file

@ -13,6 +13,8 @@ module Sidekiq
attr_accessor :manager, :poller, :fetcher
STATS_TTL = 5*365*24*60*60
def initialize(options)
@manager = Sidekiq::Manager.new(options)
@poller = Sidekiq::Scheduled::Poller.new
@ -81,8 +83,12 @@ module Sidekiq
conn.multi do
conn.incrby("stat:processed", procd)
conn.incrby("stat:processed:#{nowdate}", procd)
conn.expire("stat:processed:#{nowdate}", STATS_TTL)
conn.incrby("stat:failed", fails)
conn.incrby("stat:failed:#{nowdate}", fails)
conn.expire("stat:failed:#{nowdate}", STATS_TTL)
conn.del(workers_key)
Processor::WORKER_STATE.each_pair do |tid, hash|
conn.hset(workers_key, tid, Sidekiq.dump_json(hash))