set method

void set(
  1. String key,
  2. dynamic value, {
  3. Duration? validFor,
})

Sets value for given key with Duration

Implementation

void set(String key, dynamic value, {Duration? validFor}) {
  _listeners.forEach((listener) {
    listener.keySet(key);
  });

  this._map[key] = value;
  if (validFor != null) {
    this._map[_withValidSuffix(key)] =
        DateTime.now().add(validFor).toIso8601String();
  } else {
    if (this._map.containsKey(_withValidSuffix(key))) {
      this._map.remove(_withValidSuffix(key));
    }
  }
}