rememberForever<T> static method

Future<void> rememberForever<T>(
  1. String key,
  2. Future<T> function()
)

Stores a value in the cache with the specified key without an expiration time.

  • Parameter key The unique identifier for the cached value.
  • Parameter function A function that returns the value to be cached.
  • Throws: An error if there is an issue during the cache storage process or while executing the function. Usage:
await Cache.rememberForever<User>(
  "user",
  () async => await fetchUserFromApi(),
);

Implementation

static Future<void> rememberForever<T>(
  String key,
  Future<T> Function() function,
) async {
  final result = await function();
  await put<T>(key, result);
}