prevent a single image queuing 10+ jobs
This commit is contained in:
parent
023af6527f
commit
41177bc37a
@ -4,7 +4,6 @@ class UpdateExternalCacheJob < ApplicationJob
|
|||||||
queue_as :cache
|
queue_as :cache
|
||||||
|
|
||||||
def perform(image)
|
def perform(image)
|
||||||
return unless image.cache_expired? || image.cached_data.blank?
|
|
||||||
image.update_cache!
|
image.update_cache!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -145,7 +145,9 @@ class ExternalAPIImage < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_cache
|
def update_cache
|
||||||
|
return if @cache_updated
|
||||||
UpdateExternalCacheJob.perform_later(self)
|
UpdateExternalCacheJob.perform_later(self)
|
||||||
|
@cache_updated = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_cache!
|
def update_cache!
|
||||||
|
Loading…
Reference in New Issue
Block a user