add method
void
add(
- String key,
- dynamic value, {
- bool autoRemove = true,
- Duration expiration = const Duration(seconds: 60),
- bool listen = true,
override
Add a key/value pair to the cache, if the key is not already in the cache. Specify the duration of the cache entry (default 30 seconds).
Implementation
@override
void add(
String key,
dynamic value, {
bool autoRemove = true,
Duration expiration = const Duration(seconds: 60),
bool listen = true,
}) {
if (_cache.containsKey(key)) {
update(key, (oldValue) => value);
return;
}
_cache[key] = value;
if (autoRemove) {
_autoRemove(key, expiration);
}
if (listen) {
_notifyListeners();
}
}