cache method

void cache(
  1. String key,
  2. T value, {
  3. Duration? cacheDuration,
})

Caches a value with a given key.

If cacheDuration is set, the entry will automatically expire.

Implementation

void cache(String key, T value, {Duration? cacheDuration}) {
  _cache[key] = _CachedItem(value, cacheDuration);
  if (cacheDuration != null) {
    _startExpiration(key, cacheDuration);
  }
}