putString method

void putString({
  1. required String cacheKey,
  2. required String value,
  3. Duration duration = const Duration(),
})

缓存有效数据 cacheKey 缓存key value 缓存数据 duration 缓存时间

Implementation

void putString({required String cacheKey, required String value, Duration duration = const Duration()}) {
  if (value.isEmptyString) {
    return;
  }
  var map = {"startTime": System.currentTimeMillis, "duration": duration.inMilliseconds, "value": value};
  var json = JsonUtils.toJson(map);
  MmkvUtils.instance.putString(cacheKey, value: json);
}