allow for custom lock names

master
Andrew Coleman 2017-04-06 00:32:57 -04:00
parent 961e45bf97
commit 11cbd66ddb
1 changed files with 1 additions and 1 deletions

View File

@ -13,7 +13,7 @@ class UncomplicatedMutex
@verbose = opts[:verbose] @verbose = opts[:verbose]
@timeout = opts[:timeout] || 300 @timeout = opts[:timeout] || 300
@redis = opts[:redis] || Redis.new @redis = opts[:redis] || Redis.new
@lock_name = "lock:#{obj.class.name}:#{obj.id}".squeeze(":") @lock_name = opts[:lock_name] || "lock:#{obj.class.name}:#{obj.id}".squeeze(":")
@token = Digest::MD5.new.hexdigest("#{@lock_name}_#{Time.now.to_f}") @token = Digest::MD5.new.hexdigest("#{@lock_name}_#{Time.now.to_f}")
set_expiration_time set_expiration_time
end end