Last active
February 27, 2017 14:06
-
-
Save scicco/080fe0b4be8fa0e79d2e4e3d3a5926db to your computer and use it in GitHub Desktop.
10 minutes expiration for sidekiq_status items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #USE THIS INSIDE RAILS CONSOLE | |
| cursor = 0 | |
| items = [] | |
| while(cursor != -1) | |
| result = $redis.scan(cursor, match: "sidekiq:sidekiq:status*") | |
| cursor = result[0].to_i | |
| items += result[1] | |
| puts cursor | |
| if cursor == 0 | |
| cursor = -1 | |
| end | |
| end | |
| puts items.size | |
| #item = items.first | |
| max_expiration = 60 * 10 | |
| items.each do |item| | |
| ttl = $redis.ttl(item) | |
| $redis.expire(item, max_expiration) if ttl > max_expiration | |
| end; nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment