1
0
Fork 0
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:
Tobias Svensson 2013-09-16 17:29:47 +01:00
parent 2552d50722
commit 9de48c0eb9
2 changed files with 16 additions and 0 deletions

View file

@ -74,6 +74,12 @@ module Sidetiq
end
end
def unlock!
Sidekiq.redis do |redis|
redis.del(key)
end
end
private
def extract_key(key)

View file

@ -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"