put<T> abstract method

Future<void> put<T>({
  1. Duration? expiry,
  2. required String key,
  3. T? data,
})

Saves data to the cache and persists it to the disk.

If the cache is full, this will trigger the EvictionStrategy to remove an old item.

  • key: A unique string to identify the data.
  • data: The dynamic data to store (must be JSON encodable).
  • expiry: Optional. How long this specific item should live. If null, uses the default from config.

Example:

await Cache.put('user_id', 123, expiry: Duration(minutes: 5));

Implementation

Future<void> put<T>({Duration? expiry, required String key, T? data});