tryAcquire method

bool tryAcquire()

Tries to record one event now: returns true and logs it if fewer than limit events fall in the current window, false otherwise (not logged). Audited: 2026-06-12 11:26 EDT

Implementation

bool tryAcquire() {
  final DateTime now = _now();
  _prune(now);
  if (_events.length < limit) {
    _events.add(now);
    return true;
  }
  return false;
}