cleanExpired method

Future<void> cleanExpired()

清理过期数据(仅 persistent/hybrid 模式有效)

Implementation

Future<void> cleanExpired() async {
  await _persistentCache?.cleanExpired();

  // hybrid 模式:同步清理内存中的过期 key
  if (mode == CacheMode.hybrid && _memoryCache != null) {
    final validKeys = _persistentCache?.keys.toSet() ?? {};
    final memoryKeys = _memoryCache!.keys.toList();
    for (final key in memoryKeys) {
      if (!validKeys.contains(key)) {
        _memoryCache!.remove(key);
      }
    }
  }
}