set method
Cache content for a URL
Implementation
Future<void> set(
String url,
String content, {
Duration? expiry,
}) async {
final key = _generateKey(url);
final expiryDuration = expiry ?? _config.defaultExpiry;
final now = DateTime.now();
final entry = CacheEntry(
content: content,
cachedAt: now,
expiresAt: now.add(expiryDuration),
url: url,
);
_memoryCache[key] = entry;
// Enforce cache size limits
await _enforceLimits();
// Persist to disk if enabled
if (_config.persistToDisk && _cacheFile != null) {
await _saveToDisk();
}
}