def increment(amount = 1, time: Time.now)
      return amount <= 0 if max.zero?

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

      timestamp = (time.to_f * 1000).to_i
      argv = [timestamp, amount.to_i, max, period * 1000]

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

      !!result
    end
def increment(amount = 1, time: Time.now)
      return amount <= 0 if max.zero?

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

      timestamp = (time.to_f * 1000).to_i
      argv = [timestamp, amount.to_i, max, period * 1000]

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

      !!result
    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. Time of increment can be specified optionally with a keyword
 argument, which is useful for rolling back with a decrement.

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