set method

Future<RespType> set(
  1. String key,
  2. Object value, {
  3. ExpireMode? expire,
  4. SetMode? mode,
  5. bool get = false,
})

Implementation

Future<RespType> set(String key, Object value, {ExpireMode? expire, SetMode? mode, bool get = false}) async {
  final expireTime = expire?.time;
  final expireTimestamp = expire?.timestamp;
  return tier0.execute([
    'SET',
    key,
    value,
    if (expireTime != null) ...['PX', '${expireTime.inMilliseconds}'],
    if (expireTimestamp != null) ...['PXAT', '${expireTimestamp.millisecondsSinceEpoch}'],
    if (expire != null && expireTime == null && expireTimestamp == null) 'KEEPTTL',
    if (mode == SetMode.onlyIfNotExists) 'NX',
    if (mode == SetMode.onlyIfExists) 'XX',
    if (get) 'GET',
  ]);
}