set<T> method

void set<T>(
  1. String key,
  2. T value, {
  3. Duration? ttl,
})

Store a value under key with an optional ttl.

If ttl is not provided, defaultTtl is used.

Implementation

void set<T>(String key, T value, {Duration? ttl}) {
  final entry = CacheEntry<T>(
    value,
    createdAt: DateTime.now(),
    ttl: ttl ?? defaultTtl,
  );
  _store.set(key, entry);
  _logger.debug(
    'CacheManager: cached "$key" (ttl: ${entry.ttl?.inSeconds}s)',
  );
}