put method

  1. @override
Future<void> put(
  1. String key,
  2. dynamic value, {
  3. Duration? ttl,
})
override

Stores an item in the cache for a given duration.

Implementation

@override
Future<void> put(String key, dynamic value, {Duration? ttl}) async {
  final cmd = await _getCommand();
  final encoded = jsonEncode(value);

  if (ttl != null) {
    await cmd.send_object(['SETEX', key, ttl.inSeconds, encoded]);
  } else {
    await cmd.set(key, encoded);
  }
}