RateLimit constructor
RateLimit({
- int max = 60,
- Duration per = const Duration(minutes: 1),
- RateLimitKey? key,
- String? name,
- String? store,
- CacheStore? cacheStore,
- DateTime now()?,
Implementation
RateLimit({
this.max = 60,
this.per = const Duration(minutes: 1),
RateLimitKey? key,
String? name,
this.store,
this.cacheStore,
DateTime Function()? now,
}) : key = key ?? _byIp,
name = name ?? '${max}_${per.inMilliseconds}',
_now = now ?? DateTime.now {
if (max < 1) throw ArgumentError.value(max, 'max', 'must be 1 or more');
if (per.inMilliseconds < 1) {
throw ArgumentError.value(per, 'per', 'must be 1 ms or more');
}
}