expire method

Future<void> expire(
  1. String key,
  2. Duration? ttl
)

Sets or clears the ttl of an existing entry without rewriting its value.

Implementation

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