Skip to content

Commit

Permalink
Remove pointless parameter from recover_from_script_flush.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte Rohde committed Nov 16, 2015
1 parent 725dc74 commit 3c05936
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/redlock/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,21 @@ def load_scripts
@lock_script_sha = @redis.script(:load, LOCK_SCRIPT)
end

def recover_from_script_flush(tries: 0)
yield
rescue Redis::CommandError => e
# When somebody has flushed the Redis instance's script cache, we might
# want to reload our scripts. Only attempt this once, though, to avoid
# going into an infinite loop.
if e.message.include?('NOSCRIPT') && tries.zero?
load_scripts
tries += 1
retry
else
raise
def recover_from_script_flush
retry_on_noscript = true
begin
yield
rescue Redis::CommandError => e
# When somebody has flushed the Redis instance's script cache, we might
# want to reload our scripts. Only attempt this once, though, to avoid
# going into an infinite loop.
if retry_on_noscript && e.message.include?('NOSCRIPT')
load_scripts
retry_on_noscript = false
retry
else
raise
end
end
end
end
Expand Down

0 comments on commit 3c05936

Please sign in to comment.