cleanExpired method
清理过期数据
Implementation
Future<void> cleanExpired() async {
if (!hasExpiration) return;
for (final key in _keysIndex.toList()) {
final json = CacheServiceCore.getMap(_itemKey(key));
if (json != null) {
final entry = _parseFromDisk(json);
if (entry == null || entry.isExpired) {
await _removeFromDisk(key);
}
} else {
// 数据不存在,清理索引
_keysIndex.remove(key);
}
}
await _saveIndex();
}