def reports(keys_to_flush, suffix)
      result = []

      keys_to_flush.each_slice(REDIS_BATCH_KEYS) do |keys|
        begin
          usages = storage.pipelined { keys.each { |k| storage.hgetall(k) } }
        rescue Redis::BaseError
          # The reports in a batch where hgetall failed will not be reported
          # now, but they will not be lost. They keys will not be deleted, so
          # we will be able to retrieve them later and retry.
          # We cannot know which ones failed because we are using a pipeline.
          logger.error(SOME_REPORTS_MISSING_ERROR)
        else
          keys.each_with_index do |key, i|
            # hgetall returns {} for keys that do not exist. That can happen
            # for 2 reasons:
            # 1) Apicast-xc does not guarantee that a key in the set of cached
            # reports will always exist.
            # 2) We failed to rename the key in the previous step.
            unless usages[i].empty?
              service_id, creds = storage_keys.service_and_creds(key, suffix)
              result << { service_id: service_id,
                          credentials: creds,
                          usage: usages[i] }
            end
          end
          delete(keys)
        end
      end

      result
    end
def reports(keys_to_flush, suffix)
      result = []

      keys_to_flush.each_slice(REDIS_BATCH_KEYS) do |keys|
        begin
          usages = storage.pipelined { keys.each { |k| storage.hgetall(k) } }
        rescue Redis::BaseError
          # The reports in a batch where hgetall failed will not be reported
          # now, but they will not be lost. They keys will not be deleted, so
          # we will be able to retrieve them later and retry.
          # We cannot know which ones failed because we are using a pipeline.
          logger.error(SOME_REPORTS_MISSING_ERROR)
        else
          keys.each_with_index do |key, i|
            # hgetall returns {} for keys that do not exist. That can happen
            # for 2 reasons:
            # 1) Apicast-xc does not guarantee that a key in the set of cached
            # reports will always exist.
            # 2) We failed to rename the key in the previous step.
            unless usages[i].empty?
              service_id, creds = storage_keys.service_and_creds(key, suffix)
              result << { service_id: service_id,
                          credentials: creds,
                          usage: usages[i] }
            end
          end
          delete(keys)
        end
      end

      result
    end
Returns a report (hash with service_id, credentials, and usage) for each of
 the keys received.