Class: EdgeCacheWorker
- Inherits:
-
Object
- Object
- EdgeCacheWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/edge_cache_worker.rb
Instance Method Summary collapse
-
#perform(options = {}) ⇒ Object
Purge Cloudflare edge cache using either URLs, tags, or everything.
Instance Method Details
#perform(options = {}) ⇒ Object
Purge Cloudflare edge cache using either URLs, tags, or everything
Examples:
EdgeCacheWorker.perform_async('urls' => ['https://example.com/page1', 'https://example.com/page2'])
EdgeCacheWorker.perform_async('tags' => ['post', 'product'])
EdgeCacheWorker.perform_async('purge_everything' => true)
EdgeCacheWorker.perform_async('purge_everything' => true, 'environment' => :staging)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/workers/edge_cache_worker.rb', line 21 def perform( = {}) = .with_indifferent_access urls = [:urls] || [] = [:tags] || [] purge_everything = [:purge_everything] environment = [:environment]&.to_sym if purge_everything logger.debug(" ** Edge Cache Worker execution starting, purging everything") res = Cache::EdgeCacheUtility.instance.purge_everything(environment) logger.info ' ** EdgeCacheUtility purge everything completed.' elsif urls.present? logger.debug(" ** Edge Cache Worker execution starting", url_count: urls&.size) res = Cache::EdgeCacheUtility.instance.purge_url(urls) logger.info ' ** EdgeCacheUtility URL purge completed.' elsif .present? logger.debug(" ** Edge Cache Worker execution starting", tag_count: &.size) res = Cache::EdgeCacheUtility.instance.() logger.info ' ** EdgeCacheUtility tag purge completed.' else logger.error("Edge Cache worker, missing urls, tags, or purge_everything parameter, args were #{.inspect}") return end res end |