Skip to content

Commit

Permalink
Add TTL for stats keys
Browse files Browse the repository at this point in the history
This change adds a 5 years TTL on redis keys containing daily stats. See #3905 for more details
  • Loading branch information
odarriba authored and mperham committed Aug 6, 2018
1 parent e339d23 commit 03e63b8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/sidekiq/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 03e63b8

Please sign in to comment.