lib/picky/backends/redis.rb in picky-4.12.12 vs lib/picky/backends/redis.rb in picky-4.12.13

- old
+ new

@@ -188,19 +188,10 @@ end # Call the newly installed / super class version. # ids combinations, amount, offset end - - # # TODO - # # - # def add id, str_or_sym, weight_strategy, similarity_strategy, where - # - # - # weight = weight_strategy.weight_for ids.size - # similar = similarity_strategy.encode str_or_sym - # end # Generate a multiple host/process safe result id. # # Note: Generated when this class loads. # @@ -233,11 +224,11 @@ # begin if identifiers.size > 1 # Reuse script already installed in Redis. # - # Note: This may raise an error in Redis, + # Note: This raises an error in Redis, # when the script is not installed. # client.evalsha @ids_script_hash, identifiers, [ @@ -250,22 +241,14 @@ # client.zrange identifiers.first, offset, (offset + amount) end - rescue RuntimeError => e # Redis::CommandError + rescue ::Redis::CommandError => e # Install script in Redis. # - # TODO Use SCRIPT LOAD, then retry? - # - @ids_script_hash = Digest::SHA1.hexdigest @ids_script - client.eval @ids_script, - identifiers, - [ - generate_intermediate_result_id, - offset, - (offset + amount) - ] + @ids_script_hash = client.script 'load', @ids_script + retry end end end # Does not use Lua scripting, < Redis 2.6. \ No newline at end of file