diff --git a/lib/resque/plugins/lock.rb b/lib/resque/plugins/lock.rb index dccfff2..ef789f2 100644 --- a/lib/resque/plugins/lock.rb +++ b/lib/resque/plugins/lock.rb @@ -53,7 +53,7 @@ def lock_timeout # passed the same arguments as `perform`, that is, your job's # payload. def lock(*args) - "lock:#{name}-#{args.to_s}" + "lock:#{name}-#{Resque.encode(args)}" end # See the documentation for SETNX http://redis.io/commands/setnx for an diff --git a/test/lock_test.rb b/test/lock_test.rb index 5e4a25c..4013db9 100644 --- a/test/lock_test.rb +++ b/test/lock_test.rb @@ -42,6 +42,14 @@ def test_lock assert_equal 1, Resque.redis.llen('queue:lock_test') end + def test_lock_arguments + client_arguments = :test + client_lock = Job.lock(client_arguments) + job_arguments = Resque.decode(Resque.encode(client_arguments)) + job_lock = Job.lock(job_arguments) + assert_equal client_lock, job_lock + end + def test_deadlock now = Time.now.to_i