put<T> method

  1. @override
FutureOr<void> put<T>(
  1. String key,
  2. T object, {
  3. Duration? ttl,
})
override

Stores object under key.

ttl semantics (identical across all providers):

  • null — the TTL policy attached to this provider resolves the duration from the key. If the policy returns null the entry never expires.
  • Duration.zero — treated as "no expiry" (equivalent to the policy returning null). Do not pass Duration.zero expecting immediate eviction.
  • Any positive Duration — the entry expires after that duration.

Both providers (memory and Redis) honor these semantics identically and store a structural deep copy of object, so caller mutations after put cannot corrupt the cached value.

Implementation

@override
FutureOr<void> put<T>(String key, T object, {Duration? ttl}) =>
    store[key] = object;