0.0
No commit activity in last 3 years
No release in over 3 years
Add some methods to queue_classic to determine whether a job exists or how many times a given job is already queued.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

qc-additions

This gem adds some methods to queue_classic queues that I found helpful:

  • enqueue_if_not_queued(method, *args)
  • job_count(method, *args)
  • job_exists?(method, *args)

An index might help to speed up the job_count and job_exists? queries. Although, I haven't really tested if there is much to gain by adding this:

CREATE INDEX idx_qc_unlocked_job_count ON queue_classic_jobs (q_name, method, args) WHERE locked_at IS NULL;

Caveats when comparing args column

The method arguments are serialized to JSON. However, the comparison performed when looking for jobs in the database is a string comparison. Results might be incorrect if there is more than one way to serialize the arguments to a JSON string. It should be safe for simple things like passing a numeric id.


I have some of the original code from there: