Class: QaServer::JobIdCache
- Inherits:
-
Object
- Object
- QaServer::JobIdCache
- Defined in:
- app/cache_processors/qa_server/job_id_cache.rb
Class Method Summary collapse
-
.active_job_id?(job_key:, job_id:, expires_in: 30.minutes) ⇒ Boolean
Is the passed in job_id the active one for the job_key?.
-
.reset_job_id(job_key:) ⇒ Object
Delete cache for job id for the job represented by job_key.
Class Method Details
.active_job_id?(job_key:, job_id:, expires_in: 30.minutes) ⇒ Boolean
Note:
When job completes, call reset_job_id to invalidate the cache
Is the passed in job_id the active one for the job_key?
11 12 13 14 |
# File 'app/cache_processors/qa_server/job_id_cache.rb', line 11 def active_job_id?(job_key:, job_id:, expires_in: 30.minutes) cached_job_id = Rails.cache.fetch(cache_key(job_key), expires_in: expires_in, race_condition_ttl: 5.minutes) { job_id } cached_job_id == job_id end |
.reset_job_id(job_key:) ⇒ Object
Delete cache for job id for the job represented by job_key. Call this when the job completes.
18 19 20 |
# File 'app/cache_processors/qa_server/job_id_cache.rb', line 18 def reset_job_id(job_key:) Rails.cache.delete(cache_key(job_key)) end |