Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

resque plugin to add unique jobs

License

NotificationsYou must be signed in to change notification settings

neighborland/resque_solo

Repository files navigation

Gem VersionBuild Status

ResqueSolo is a resque plugin to add unique jobs to resque.

It is a re-write ofresque-loner.

It requires resque 1.25 or greater and works with ruby 2.3 and later.

It removes the dependency onResque::Helpers, which is deprecated for resque 2.0.

Install

Add the gem to your Gemfile:

gem"resque_solo"

Usage

classUpdateCatincludeResque::Plugins::UniqueJob@queue=:catsdefself.perform(cat_id)# do somethingendend

If you attempt to queue a unique job multiple times, it is ignored:

Resque.enqueue UpdateCat, 1=> trueResque.enqueue UpdateCat, 1=> nilResque.enqueue UpdateCat, 1=> nilResque.size :cats=> 1Resque.enqueued? UpdateCat, 1=> trueResque.enqueued_in? :dogs, UpdateCat, 1=> false

Options

lock_after_execution_period

By default, lock_after_execution_period is 0 andenqueued? becomes false as soon as the jobis being worked on.

Thelock_after_execution_period setting can be used to delay when the unique job key is deleted(i.e. whenenqueued? becomesfalse). For example, if you have a long-running unique job thattakes around 10 seconds, and you don't want to requeue another job until you are sure it is done,you could setlock_after_execution_period = 20. Or if you never want to run a long runningjob more than once per minute, setlock_after_execution_period = 60.

classUpdateCatincludeResque::Plugins::UniqueJob@queue=:cats@lock_after_execution_period=20defself.perform(cat_id)# do somethingendend

ttl

By default the created keys have no expiration time, and this gems removes thekeys once the job is completed successfully.

If you want to set an expiration time on Redis-level though, you can use thettl option.

classUpdateCatincludeResque::Plugins::UniqueJob@queue=:cats@ttl=3600# in secondsdefself.perform(cat_id)# do somethingendend

Development

Clone this repository, then:

Run tests with resque 1.x locally:

bundlebundleexec raketest

Test supported versions of resque locally:

appraisal installappraisal raketest

About

resque plugin to add unique jobs

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp