I'm storing some key generated by users in a IDistributedCache
set up.
The key are long lived and they can be manually revoked by an user, if the user knows each one of them:
public void ConfigureServices(IServiceCollection services)
{
services.AddDistributedMemoryCache();
//...
}
//ControllerBase:
//Adding the key:
await _cache.SetAsync(userKey, userId, new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(10)
});
//Removing the key:
await _cache.RemoveAsync(key);
Now, what I want to do is to be able to list all keys still present in the cache that were created by one of the users. Also, I want to be able to bulk delete them.
Is there such a functionality available right now? Maybe with cancelation tokens? How can I do that?