invalidateWhere method
Invalidates cache entries that match the given test
condition.
The test
function is applied to each key-value pair in the cache.
If the test returns true, the entry is removed from the cache.
Implementation
Future<void> invalidateWhere(
bool Function(String key, dynamic value) test) async {
try {
final keys = await _cacheAdapter.getKeys();
for (final key in keys) {
final value = await _cacheAdapter.get(key);
if (value != null && test(key, value.value)) {
await delete(key);
}
}
} catch (e) {
_log.severe('Failed to invalidate cache entries (Unknown Error): $e');
throw CacheException('Failed to invalidate cache entries: $e');
}
}