get<T> method

Future<T?> get<T>(
  1. String key
)

Retrieves a value from the cache.

Implementation

Future<T?> get<T>(String key) async {
  if (!_store.containsKey(key)) {
    return null;
  }

  final entry = _store[key]!;
  if (entry.expiration != null && NyTime.now().isAfter(entry.expiration!)) {
    _store.remove(key);
    return null;
  }

  return entry.value as T?;
}