Module: Resque::Plugins::Unique
- Defined in:
- lib/resque/plugins/unique.rb
Instance Method Summary collapse
- #around_perform_unique(*args) ⇒ Object
- #before_enqueue_unique(*args) ⇒ Object
- #lock(*args) ⇒ Object
- #lock_timeout ⇒ Object
Instance Method Details
#around_perform_unique(*args) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/resque/plugins/unique.rb', line 16 def around_perform_unique(*args) begin yield ensure # Always clear the lock when we're done, even if there is an # error. Resque.redis.del(lock(*args)) end end |
#before_enqueue_unique(*args) ⇒ Object
12 13 14 |
# File 'lib/resque/plugins/unique.rb', line 12 def before_enqueue_unique(*args) acquire_lock(*args) end |
#lock(*args) ⇒ Object
4 5 6 |
# File 'lib/resque/plugins/unique.rb', line 4 def lock(*args) "unique:#{name}-#{normalised_args(*args).to_s}" end |
#lock_timeout ⇒ Object
8 9 10 |
# File 'lib/resque/plugins/unique.rb', line 8 def lock_timeout @lock_timeout || 3_600 #seconds end |