Module: Resque::Plugins::UniqueJob::ClassMethods
- Defined in:
- lib/resque_solo/unique_job.rb
Instance Method Summary collapse
-
#lock_after_execution_period ⇒ Object
The default ttl of a persisting key is 0, i.e.
-
#redis_key(payload) ⇒ Object
Payload is what Resque stored for this job along with the job’s class name: a hash containing :class and :args.
-
#ttl ⇒ Object
The default ttl of a locking key is -1 (forever).
Instance Method Details
#lock_after_execution_period ⇒ Object
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
45 46 47 |
# File 'lib/resque_solo/unique_job.rb', line 45 def lock_after_execution_period @lock_after_execution_period ||= 0 end |
#redis_key(payload) ⇒ Object
Payload is what Resque stored for this job along with the job’s class name: a hash containing :class and :args
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/resque_solo/unique_job.rb', line 13 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 ⇒ Object
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
32 33 34 |
# File 'lib/resque_solo/unique_job.rb', line 32 def ttl @ttl ||= -1 end |