Module: Resque::Plugins::UniqueAtRuntime

Defined in:
lib/resque/plugins/unique_at_runtime.rb

Overview

If you want your job to support uniqueness at runtime, simply include this module into your job class.

class RunAlone
@queue = :run_alone
include Resque::Plugins::UniqueAtRuntime

def self.perform(arg1, arg2)
  alone_stuff
end
end

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

ATOMIC_LOCK_SCRIPT =
<<~LUA
  local previous_timeout = redis.call("HGET", KEYS[1], ARGV[1])
  if previous_timeout and tonumber(previous_timeout) > tonumber(ARGV[3]) then
    return 0
  end
  redis.call("HSET", KEYS[1], ARGV[1], ARGV[2])
  return 1
LUA
LEGACY_LOCK_MUTEX =
Mutex.new

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



28
29
30
# File 'lib/resque/plugins/unique_at_runtime.rb', line 28

def self.included(base)
  base.extend ClassMethods
end