@@ -169,6 +169,7 @@ def initialize(connection)
169169 def lock ( resource , val , ttl , allow_new_lock )
170170 recover_from_script_flush do
171171 @redis . with { |conn |
172+ # NOTE: is idempotent and safe to retry
172173 conn . call ( 'EVALSHA' , Scripts ::LOCK_SCRIPT_SHA , 1 , resource , val , ttl , allow_new_lock )
173174 }
174175 end
@@ -177,6 +178,7 @@ def lock(resource, val, ttl, allow_new_lock)
177178 def unlock ( resource , val )
178179 recover_from_script_flush do
179180 @redis . with { |conn |
181+ # NOTE: is idempotent and safe to retry
180182 conn . call ( 'EVALSHA' , Scripts ::UNLOCK_SCRIPT_SHA , 1 , resource , val )
181183 }
182184 end
@@ -187,6 +189,7 @@ def unlock(resource, val)
187189 def get_remaining_ttl ( resource )
188190 recover_from_script_flush do
189191 @redis . with { |conn |
192+ # NOTE: is idempotent and safe to retry
190193 conn . call ( 'EVALSHA' , Scripts ::PTTL_SCRIPT_SHA , 1 , resource )
191194 }
192195 end
@@ -205,6 +208,7 @@ def load_scripts
205208
206209 @redis . with do |connnection |
207210 scripts . each do |script |
211+ # NOTE: is idempotent and safe to retry
208212 connnection . call ( 'SCRIPT' , 'LOAD' , script )
209213 end
210214 end
0 commit comments