module Resque::Plugins::UniqueJob::ClassMethods

Public Instance Methods

lock_after_execution_period() click to toggle source

The default ttl of a persisting key is 0, i.e. immediately deleted. Set lock_after_execution_period to block the execution of the job for a certain amount of time (in seconds). For example:

class FooJob

include Resque::Plugins::UniqueJob
@lock_after_execution_period = 40

end

# File lib/resque_solo/unique_job.rb, line 47
def lock_after_execution_period
  @lock_after_execution_period ||= 0
end
redis_key(payload) click to toggle source

Payload is what Resque stored for this job along with the job's class name: a hash containing :class and :args

# File lib/resque_solo/unique_job.rb, line 15
def redis_key(payload)
  payload = Resque.decode(Resque.encode(payload))
  job  = payload["class"]
  args = payload["args"]
  args.map! do |arg|
    arg.is_a?(Hash) ? arg.sort : arg
  end

  Digest::MD5.hexdigest Resque.encode(class: job, args: args)
end
ttl() click to toggle source

The default ttl of a locking key is -1 (forever). To expire the lock after a certain amount of time, set a ttl (in seconds). For example:

class FooJob

include Resque::Plugins::UniqueJob
@ttl = 40

end

# File lib/resque_solo/unique_job.rb, line 34
def ttl
  @ttl ||= -1
end