RateLimit constructor

RateLimit({
  1. int max = 60,
  2. Duration per = const Duration(minutes: 1),
  3. RateLimitKey? key,
  4. String? name,
  5. String? store,
  6. CacheStore? cacheStore,
  7. 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');
  }
}