invalidateKeys method
Invalidate specific cache keys The full key has to be provided to invalidate the instance. So if the user, for example, has been provided with the parameter of id - we need to provide the user_{id.hasCode} to invalidate it.
Implementation
void invalidateKeys(List<String> keys) {
final validKeysToInvalidate = keys
.where((key) => _cacheStorage.hasKey(key))
.toList();
for (final key in validKeysToInvalidate) {
_cacheStorage.removeKey(key);
}
// Notify listeners
if (validKeysToInvalidate.isNotEmpty) {
_invalidationController.add(
CacheInvalidationEvent(invalidatedKeys: validKeysToInvalidate),
);
}
}