rememberForever<T> static method
Stores a value in the cache with the specified key without an expiration time.
- Parameter
keyThe unique identifier for the cached value. - Parameter
functionA 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);
}