
Security News
Oxlint Introduces Type-Aware Linting Preview
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Multiple identical jobs are wasteful. Uniqueue ensures that for a given queue, identical jobs are never enqueued, and you can stress a little less about your application code causing duplicate work.
Uniqueue uses Lua scripting, which requires Redis 2.6 or greater, so make sure your Redis installation is up to date.
Before deploying an application with Uniqueue enabled for the first time, it's important that you ensure your queues are empty.
Add Uniqueue to your Gemfile.
gem 'resque-uniqueue'
Then run bundle install within your app's directory.
You'll need to configure Uniqueue somewhere in your application's initialization process. If you are running a Rails application it's recommended you use your Resque initializer:
# config/initializers/resque.rb
Resque.unique_queues!
By default Uniqueue defaults to preventing identical jobs on all queues. However, if you need to scope Uniqueue to specific queues, then your intializer code should look like this:
# config/initializers/resque.rb
Resque.unique_queues = ["emails", "orders"]
Resque.unique_queues!
Uniqueue overrides 3 resque commands: push
, pop
, and remove_queue
in order to enforce queue-level uniqueness of jobs. And for each queue two additional Redis keys are created:
queue:[queue_name]:uniqueue
- A set containing MultiJSON dumps of the payload of all items on the queuequeue:[queue_name]:start_at
- A list containing the Unix timestamp of each job on the queue's start time, ordered identically to the actual job queueNow when Resque pushes a job the following happens:
sadd
on the payload (well, a MultiJSON dump of it), which will add it to the uniqueue set if it is not already a member.rpush
the start time of the job to the start_at list and rpush
the job to the queue (following the lead of Resque's default push
command).Because the three operations happen in the context of a Lua script, atomicity is guaranteed (See "Atomicity of Scripts" here), and race conditions can never cause the uniqueue set, start_at list, and original queue to get out of sync. Each unique job is now successfully queued, its payload is present in our uniqueue set, and its start_at timestamp is on a list that corresponds exactly to the order of the queue list.
Popping a job is very similar:
And this is how a unique job is born.
Copyright (c) 2013 AcademicWorks, inc. See LICENSE.txt for further details.
FAQs
Unknown package
We found that resque-uniqueue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.