get static method
Implementation
static Future<dynamic> get(String key) async {
// memory first
final m = _mem[key];
if (m != null) {
if (!m.expired) {
AutoPilotLogger.cache('HIT(mem)', key);
return m.data;
}
_mem.remove(key);
}
// disk fallback
try {
final raw = ApStorage.get<String>('$_prefix$key');
if (raw != null) {
final j = jsonDecode(raw) as Map<String, dynamic>;
final exp = DateTime.fromMillisecondsSinceEpoch(j['e'] as int);
if (DateTime.now().isBefore(exp)) {
_mem[key] = _Entry(j['d'], exp);
AutoPilotLogger.cache('HIT(disk)', key);
return j['d'];
}
await ApStorage.remove('$_prefix$key');
}
} catch (_) {}
AutoPilotLogger.cache('MISS', key);
return null;
}