Open
Description
As @eerhardt and I were triaging through caching extensions issues, we noticed a theme of requests being around allowing for key enumeration and bulk removal of items in IDistributedCache:
- How to flush all cache? #36547: How to flush all cache
- Bulk remove on IDistributedCache #36568: Bulk remove on IDistributedCache
- How to get the list of keys using IDistributedCache extension. #36402: Enumerating keys using IDistributedCache
We closed a number of items as dupes of the above issues as well.
More information on the intricacies of this issue and ways to approach it:
- When using caching in extensions, we don't want to allow enumerating on keys while elements may get removed within another thread, (keeping as atomic operation). In order to allow for (e.g. bulk remove) we can offer returning a snapshot (say array of elements. For example to allow for bulk remove of items with a certain prefix (e.g. "ZZZ"), given a snapshot, we may use TryGetValue and if already gone it would not throw.