# frozen_string_literal: true require "redis" # This returns a hash # The keys are the bitcoin addresses, the values are all of the keys which # contain that address # If there are no duplicates, then each value will be a singleton list def get_addresses_with_users(redis) addrs = Hash.new { |h, k| h[k] = [] } # I picked 1000 because it made a relatively trivial case take 15 seconds # instead of forever. # Basically it's "how long does each command take" # The lower it is (default is 10), it will go back and forth to the client a # ton redis.scan_each(match: "jmp_customer_btc_addresses-*", count: 1000) do |key| redis.smembers(key).each do |addr| addrs[addr] << key end end addrs end module RedisBtcAddresses def self.each_user(redis) # I picked 1000 because it made a relatively trivial case take # 15 seconds instead of forever. # Basically it's "how long does each command take" # The lower it is (default is 10), it will go back and forth # to the client a ton redis.scan_each( match: "jmp_customer_btc_addresses-*", count: 1000 ) do |key| yield key, redis.smembers(key) end end end