addWithKey method

void addWithKey(
  1. String key,
  2. T value,
  3. int ts
)

Implementation

void addWithKey(String key, T value, int ts) {
  if (value == null) return;
  final existData = _cachedDataMap[key];
  if (existData == null) {
    final newData = CachedData<T>(value: value, ts: ts);
    _cachedDataMap[key] = newData;
  } else if (existData.ts < ts) {
    existData.value = value;
    existData.ts = ts;
  }

  if (_cachedDataMap.length == 1) (policy as PeriodEviction).start();
}