DatabaseRateLimitedRequestAttemptUtil<T> class

Utility class for tracking and rate limiting request attempts.

This class provides a reusable mechanism for rate limiting requests based on:

  • Attempt count: Limits the total number of attempts
  • Timeframe: Limits attempts within a rolling window

Both mechanisms can be used together, but at least one must be provided.

The T type parameter represents the type of the nonce.

This rate limiting implementation uses the RateLimitedRequestAttempt model to track attempts. Each attempt is logged in a separate transaction that is never rolled back, ensuring rate limiting is always enforced.

Inheritance

Properties

config → RateLimitedRequestAttemptConfig<T>
The configuration for the rate limiting.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

countAttempts(Session session, {required T nonce, Transaction? transaction}) → Future<int>
Counts the number of attempts for the given nonce.
override
deleteAttempts(Session session, {T? nonce, Duration? olderThan, Transaction? transaction}) → Future<int>
Deletes all attempts that match the given filters.
override
hasTooManyAttempts(Session session, {required T nonce, Map<String, String>? extraData}) → Future<bool>
Records and attempts and checks if there have been too many attempts for the given nonce.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordAttempt(Session session, {required T nonce, Map<String, String>? extraData, Transaction? transaction}) → Future<void>
Records an attempt for the given nonce.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited