class Redis::Cluster
def try_send(node, method_name, *args, retry_count: 3, &block)
- See: https://redis.io/topics/cluster-spec#redirection-and-resharding -
def try_send(node, method_name, *args, retry_count: 3, &block) node.public_send(method_name, *args, &block) rescue CommandError => err if err.message.start_with?('MOVED') raise if retry_count <= 0 node = assign_redirection_node(err.message) retry_count -= 1 retry elsif err.message.start_with?('ASK') raise if retry_count <= 0 node = assign_asking_node(err.message) node.call(%i[asking]) retry_count -= 1 retry else raise end rescue CannotConnectError update_cluster_info! raise end