peekExpired method

  1. @override
  2. @server
  3. @client
Future<Stream<String>> peekExpired({
  1. DateTime? asOf,
  2. int? limit,
})
override

Up to limit keys whose expiry instant is at-or-before asOf (default: now), in ascending-expiry order. limit: 1 answers "which key is next to expire". limit: null means no limit — the same set as getExpiredKeys, but with guaranteed ascending-expiry ordering. Ties (same expiry instant) are yielded in implementation-defined order.

Bounded counterpart to getExpiredKeys — use this for next-up probes and batched sweeps; the unbounded variant stays for the "drain everything" caller.

The returned Future completes once the backend has accepted the request; the Stream then yields the keys (empty stream if none match). Snapshot semantics as for nextExpiresAt.

Implementation

@override
@server
@client
Future<Stream<String>> peekExpired({DateTime? asOf, int? limit}) async {
  final cutoff = asOf ?? DateTime.timestamp();
  return Stream.fromIterable(
      _collectAscending(expiresAt, limit, (t) => !t.isAfter(cutoff)));
}