getIfPresent method
Get cached data if present and not expired, returns null otherwise Does NOT call fetcher - just returns what's in cache
Implementation
Future<dynamic> getIfPresent(dynamic key) async {
final normalizedKey = _normalizeKey(key);
final entry = _metadata[normalizedKey];
if (entry != null && !_isExpired(entry)) {
// Update access metadata
final updatedEntry = entry.copyWith(
lastAccessTime: DateTime.now(),
accessCount: entry.accessCount + 1,
);
_metadata[normalizedKey] = updatedEntry;
await storage.write(normalizedKey, jsonEncode(updatedEntry.toJson()));
return entry.data;
}
return null;
}