validateTtl method

  1. @override
void validateTtl(
  1. Duration ttl
)
override

Validates a TTL duration. Throws CacheException if the TTL is invalid.

Implementation

@override
void validateTtl(Duration ttl) {
  if (ttl.isNegative) {
    throw CacheException('TTL duration cannot be negative');
  }

  // Check for unreasonably long TTL
  const maxTtl = Duration(days: 365 * 10); // 10 years
  if (ttl > maxTtl) {
    throw CacheException('TTL duration is too long (maximum 10 years)');
  }
}