Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Resque plugin for ensuring only one instance of your job is running at a time.

branch: master

1.1

latest commit d364a7e9aa
Chris Wanstrath authored November 08, 2012
Octocat-spinner-32 lib Implment an algorithm to prevent deadlocks November 06, 2012
Octocat-spinner-32 test Implment an algorithm to prevent deadlocks November 06, 2012
Octocat-spinner-32 .gitignore gitignore August 18, 2011
Octocat-spinner-32 Gemfile Gemfile August 18, 2011
Octocat-spinner-32 LICENSE ray is the man August 18, 2011
Octocat-spinner-32 README.md update readme August 18, 2011
Octocat-spinner-32 Rakefile old school August 18, 2011
Octocat-spinner-32 resque-lock.gemspec 1.1 November 08, 2012
README.md

Resque Lock

A Resque plugin. Requires Resque 1.7.0.

If you want only one instance of your job queued at a time, extend it with this module.

For example:

require 'resque/plugins/lock'

class UpdateNetworkGraph
  extend Resque::Plugins::Lock

  def self.perform(repo_id)
    heavy_lifting
  end
end

While this job is queued or running, no other UpdateNetworkGraph jobs with the same arguments will be placed on the queue.

If you want to define the key yourself you can override the lock class method in your subclass, e.g.

class UpdateNetworkGraph
  extend Resque::Plugins::Lock

  Run only one at a time, regardless of repo_id.
  def self.lock(repo_id)
    "network-graph"
  end

  def self.perform(repo_id)
    heavy_lifting
  end
end

The above modification will ensure only one job of class UpdateNetworkGraph is queued at a time, regardless of the repo_id. Normally a job is locked using a combination of its class name and arguments.

Something went wrong with that request. Please try again.