def increment(amount = 1, time: Time.now)
      return true if amount == 0
      return false if max == 0
      raise ArgumentError.new("Amount must be positive") if amount < 0

      if amount != amount.to_i
        raise ArgumentError.new("Amount must be an integer")
      end

      return false if amount > max

      incrby = (period * 1000 * amount / max).to_i
      argv = [incrby, period * 1000]

      result =
        begin
          redis.evalsha(
            Scripts::INCREMENT_GCRA_HASH, keys: [key], argv: argv)
        rescue Redis::CommandError
          redis.eval(Scripts::INCREMENT_GCRA, keys: [key], argv: argv)
        end

      case result
      when 0
        return true
      when -1
        raise Errors::InvalidKeyError, "Redis key #{key} has no expire time set"
      when -2
        return false
      else
        raise Errors::UnknownReturnValue,
              "Received unexpected return value #{result} from " \
              "increment_gcra eval"
      end
    end
def increment(amount = 1, time: Time.now)
      return true if amount == 0
      return false if max == 0
      raise ArgumentError.new("Amount must be positive") if amount < 0

      if amount != amount.to_i
        raise ArgumentError.new("Amount must be an integer")
      end

      return false if amount > max

      incrby = (period * 1000 * amount / max).to_i
      argv = [incrby, period * 1000]

      result =
        begin
          redis.evalsha(
            Scripts::INCREMENT_GCRA_HASH, keys: [key], argv: argv)
        rescue Redis::CommandError
          redis.eval(Scripts::INCREMENT_GCRA, keys: [key], argv: argv)
        end

      case result
      when 0
        return true
      when -1
        raise Errors::InvalidKeyError, "Redis key #{key} has no expire time set"
      when -2
        return false
      else
        raise Errors::UnknownReturnValue,
              "Received unexpected return value #{result} from " \
              "increment_gcra eval"
      end
    end
Increment the amount used by the given number. Does not perform increment
 if the operation would exceed the limit. Returns whether the operation was
 successful.

 @param amount [Integer] amount to increment by
 @param time [Time] time is ignored
 @return [Boolean] true if increment succeded and false if incrementing
   would exceed the limit