get<T> method
Retrieve a cached value of type T by key.
Returns null if the key doesn't exist or the entry has expired.
Expired entries are automatically evicted.
Implementation
T? get<T>(String key) {
final raw = _store.get(key);
if (raw == null) return null;
if (raw is CacheEntry) {
if (raw.isExpired) {
_logger.debug('CacheManager: entry "$key" expired — evicting');
_store.remove(key);
return null;
}
return raw.value as T;
}
// Stored without CacheEntry wrapper (shouldn't happen, but be safe).
return raw as T;
}