get<T> method
获取缓存
Implementation
@override
Future<T?> get<T>(
String key,
T Function(Map<String, dynamic>) fromJson,
) async {
if (_database == null) await initialize();
final cacheItem = await _database!.findCache(key);
if (cacheItem == null) return null;
try {
final jsonMap = jsonDecode(cacheItem.data) as Map<String, dynamic>;
return fromJson(jsonMap);
} catch (e) {
// 解析失败,删除无效缓存
await delete(key);
return null;
}
}