mirror of
https://github.com/discourse/discourse.git
synced 2025-09-08 12:06:51 +08:00
FIX: remove dependency on present? in distributed_mutex lib
This commit is contained in:
parent
78500fb770
commit
5f87089b67
1 changed files with 3 additions and 3 deletions
|
@ -83,7 +83,7 @@ class DistributedMutex
|
||||||
|
|
||||||
current_expire_time = redis.get key
|
current_expire_time = redis.get key
|
||||||
|
|
||||||
if current_expire_time.present? && current_expire_time.to_i > now
|
if current_expire_time && current_expire_time.to_i > now
|
||||||
redis.unwatch
|
redis.unwatch
|
||||||
|
|
||||||
got_lock = false
|
got_lock = false
|
||||||
|
@ -94,7 +94,7 @@ class DistributedMutex
|
||||||
redis.expire key, validity
|
redis.expire key, validity
|
||||||
end
|
end
|
||||||
|
|
||||||
got_lock = result.present?
|
got_lock = !result.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
[got_lock, expire_time]
|
[got_lock, expire_time]
|
||||||
|
@ -109,7 +109,7 @@ class DistributedMutex
|
||||||
redis.multi do
|
redis.multi do
|
||||||
redis.del key
|
redis.del key
|
||||||
end
|
end
|
||||||
return result.present?
|
return !result.nil?
|
||||||
else
|
else
|
||||||
redis.unwatch
|
redis.unwatch
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue