fetchCacheData<R, T> method
Future<R?>
fetchCacheData<R, T>(
- String key,
- SerializerBloc<
R, T> serializerBloc, - Storage storage, {
- bool keepExpiredCache = false,
- int ttlValue = defaultTTLValue,
Implementation
Future<R?> fetchCacheData<R, T>(
String key, SerializerBloc<R, T> serializerBloc, Storage storage,
{bool keepExpiredCache = false, int ttlValue = defaultTTLValue}) async {
final cacheWrapper = await read<T>(key, storage);
if (cacheWrapper == null) {
return null;
}
logCacheData(key, cacheWrapper, storage: storage, ttlValue: ttlValue);
if (cacheWrapper.expired(ttlValue, ignoreTtl: keepExpiredCache)) {
return null;
}
if (cacheWrapper.data == null) {
return null;
}
return serializerBloc(cacheWrapper.data as T);
}