From 03e63b8c99607fa45e71eb2a699324e202de80c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20de=20Arriba?= Date: Mon, 6 Aug 2018 19:46:00 +0200 Subject: [PATCH] Add TTL for stats keys This change adds a 5 years TTL on redis keys containing daily stats. See #3905 for more details --- lib/sidekiq/launcher.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/sidekiq/launcher.rb b/lib/sidekiq/launcher.rb index 80f1b4b82..85fbad622 100644 --- a/lib/sidekiq/launcher.rb +++ b/lib/sidekiq/launcher.rb @@ -12,6 +12,8 @@ class Launcher include Util attr_accessor :manager, :poller, :fetcher + + STATS_TTL = 5*365*24*60*60 def initialize(options) @manager = Sidekiq::Manager.new(options) @@ -81,8 +83,12 @@ def ❤ 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))