Class: ActiveJob::Uniqueness::LockManager
- Inherits:
-
Redlock::Client
- Object
- Redlock::Client
- ActiveJob::Uniqueness::LockManager
- Defined in:
- lib/active_job/uniqueness/lock_manager.rb
Overview
Redlock requires a value of the lock to release the resource by Redlock::Client#unlock method. LockManager introduces LockManager#delete_lock to unlock by resource key only. See github.com/leandromoreira/redlock-rb/issues/51 for more details.
Instance Method Summary collapse
-
#delete_lock(resource) ⇒ Object
Unlocks a resource by resource only.
-
#delete_locks(wildcard) ⇒ Object
Unlocks multiple resources by key wildcard.
Instance Method Details
#delete_lock(resource) ⇒ Object
Unlocks a resource by resource only.
10 11 12 13 14 15 16 17 18 |
# File 'lib/active_job/uniqueness/lock_manager.rb', line 10 def delete_lock(resource) @servers.each do |server| synced_redis_connection(server) do |conn| conn.call('DEL', resource) end end true end |
#delete_locks(wildcard) ⇒ Object
Unlocks multiple resources by key wildcard.
21 22 23 24 25 26 27 28 29 |
# File 'lib/active_job/uniqueness/lock_manager.rb', line 21 def delete_locks(wildcard) @servers.each do |server| synced_redis_connection(server) do |conn| conn.scan('MATCH', wildcard).each { |key| conn.call('DEL', key) } end end true end |