summaryrefslogtreecommitdiff
path: root/lib/gitlab/exclusive_lease.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/exclusive_lease.rb')
-rw-r--r--lib/gitlab/exclusive_lease.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/gitlab/exclusive_lease.rb b/lib/gitlab/exclusive_lease.rb
index c73eca832d7..ffe49364379 100644
--- a/lib/gitlab/exclusive_lease.rb
+++ b/lib/gitlab/exclusive_lease.rb
@@ -43,18 +43,15 @@ module Gitlab
# false if the lease is already taken.
def try_obtain
# Performing a single SET is atomic
- !!redis.set(redis_key, '1', nx: true, ex: @timeout)
+ Gitlab::Redis.with do |redis|
+ !!redis.set(redis_key, '1', nx: true, ex: @timeout)
+ end
end
# No #cancel method. See comments above!
private
- def redis
- # Maybe someday we want to use a connection pool...
- @redis ||= Redis.new(url: Gitlab::RedisConfig.url)
- end
-
def redis_key
"gitlab:exclusive_lease:#{@key}"
end