def used
      return 0 if max.zero?

      timestamp, amount = redis.hmget(key, 'timestamp', 'amount')
      if timestamp && amount
        time_passed = Time.now.to_f - timestamp.to_i / 1000.0
        drift = max * time_passed / period
        last_amount = [amount.to_f, max].min
        [(last_amount - drift).ceil, 0].max
      else
        0
      end
    end
def used
      return 0 if max.zero?

      timestamp, amount = redis.hmget(key, 'timestamp', 'amount')
      if timestamp && amount
        time_passed = Time.now.to_f - timestamp.to_i / 1000.0
        drift = max * time_passed / period
        last_amount = [amount.to_f, max].min
        [(last_amount - drift).ceil, 0].max
      else
        0
      end
    end
Return amount of limit used, taking time drift into account.

 @return [Integer] amount used