add method

  1. @override
Future<bool> add(
  1. String key,
  2. dynamic value, [
  3. Duration? ttl
])
override

Stores an item in the cache if the key does not exist.

  • key: The key under which to store the item.
  • value: The value to store.
  • ttl: The time-to-live duration for the cache item.

Returns true if the item was successfully stored.

Implementation

@override
Future<bool> add(String key, dynamic value, [Duration? ttl]) async {
  // Delegates to the store's atomic store-only-if-absent operation so
  // concurrent callers cannot both report success for the same key.
  return await store.add(await _namespaced(key), value, ttl?.inSeconds ?? 0);
}