isCacheValid method
- CacheCategory category
Check if cache for a category is valid (not expired).
Implementation
Future<bool> isCacheValid(CacheCategory category) async {
await _ensureInitialized();
try {
final timestamp = _timestampBox!.get(category.value);
if (timestamp == null) return false;
final ttl = CacheConfig.getTtlForCategory(category);
final age = DateTime.now().difference(timestamp);
return age <= ttl;
} catch (e) {
debugPrint('Error checking cache validity for ${category.value}: $e');
return false;
}
}