set method

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

Stores value under key (null removes it). With ttl the entry disappears once it elapses. Takes effect immediately for readers; the future completes once it is on disk.

Implementation

Future<void> set(String key, Object? value, {Duration? ttl}) {
  if (value == null) return remove(key);
  _put(key, value, ttl == null ? null : DateTime.now().add(ttl).millisecondsSinceEpoch);
  return _schedule();
}