mirror of
https://github.com/endofunky/sidetiq.git
synced 2022-11-09 13:53:30 -05:00
Add Lock::Redis#unlock!.
This commit is contained in:
parent
2552d50722
commit
9de48c0eb9
2 changed files with 16 additions and 0 deletions
|
@ -74,6 +74,12 @@ module Sidetiq
|
|||
end
|
||||
end
|
||||
|
||||
def unlock!
|
||||
Sidekiq.redis do |redis|
|
||||
redis.del(key)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def extract_key(key)
|
||||
|
|
|
@ -31,6 +31,16 @@ class TestLock < Sidetiq::TestCase
|
|||
assert_equal "sidetiq:Foobar:lock", locks.first.key
|
||||
end
|
||||
|
||||
def test_unlock!
|
||||
Sidekiq.redis do |redis|
|
||||
redis.set("sidetiq:Foobar:lock", 1)
|
||||
|
||||
Sidetiq::Lock::Redis.new("Foobar").unlock!
|
||||
|
||||
assert_nil redis.get("sidetiq:Foobar:lock")
|
||||
end
|
||||
end
|
||||
|
||||
def test_lock_sets_correct_meta_data
|
||||
key = SecureRandom.hex(8)
|
||||
internal_key = "sidetiq:#{key}:lock"
|
||||
|
|
Loading…
Reference in a new issue