prime method
Adds the provided key and value to the cache. If the key already exists, no change is made. Returns itself for method chaining.
Implementation
DataLoader<K, V, C> prime(K key, V value) {
final cacheMap = this._cacheMap;
if (cacheMap != null) {
final cacheKey = this._cacheKeyFn(key);
// Only add the key if it does not already exist.
if (cacheMap.get(cacheKey) == null) {
// Cache a rejected promise if the value is an Error, in order to match
// the behavior of load(key).
final Future<V> promise;
promise = Future.value(value);
cacheMap.set(cacheKey, promise);
}
}
return this;
}