init method
初始化(从磁盘恢复数据)
仅 persistent/hybrid 模式需要调用
Implementation
Future<void> init() async {
if (_initialized) return;
if (_persistentCache != null) {
await _persistentCache!.init();
// hybrid 模式:预加载磁盘数据到内存
if (mode == CacheMode.hybrid && _memoryCache != null) {
for (final key in _persistentCache!.keys) {
final value = _persistentCache!.get(key);
if (value != null) {
_memoryCache!.put(key, value);
}
}
}
}
_initialized = true;
}