isFresh method

bool isFresh(
  1. String key, {
  2. Duration? ttl,
})

Checks if the data for this key is "fresh" within a given TTL.

Implementation

bool isFresh(String key, {Duration? ttl}) {
  final entry = _l1Cache[key];
  if (entry == null) return false;
  final effectiveTtl =
      ttl ?? Duration(seconds: LikeConstants.sessionStaleTTL);
  return DateTime.now().difference(entry.timestamp) < effectiveTtl;
}