mirror of
https://github.com/neocities/neocities.git
synced 2025-05-14 00:17:26 +02:00
better structure for cache purge
This commit is contained in:
parent
be128608b9
commit
63d9348012
3 changed files with 23 additions and 9 deletions
|
@ -2,11 +2,14 @@ class PurgeCacheWorker
|
|||
include Sidekiq::Worker
|
||||
sidekiq_options queue: :purgecache, retry: 10, backtrace: true
|
||||
|
||||
def perform(url)
|
||||
def perform(payload)
|
||||
attempt = 0
|
||||
begin
|
||||
$pubsub.publish 'purgecache', url
|
||||
attempt += 1
|
||||
$pubsub.publish 'purgecache', payload.to_json
|
||||
rescue Redis::BaseConnectionError => error
|
||||
puts "Pubsub error: #{error}, retrying in 1s"
|
||||
raise if attempt > 3
|
||||
puts "pubsub error: #{error}, retrying in 1s"
|
||||
sleep 1
|
||||
retry
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue