Is there a way to clear a session cache key for all users?
For example, I am storing the users currently selected shop item under the following session key “currentItem”. In the management area of the website, I decide to delete that particular shop item. I now want to invalidate all the “currentItem” cache entries across all sessions.
Is there a way to do this?
I realise the example I have given is a little contrived, but it gets the point across. I suspect one solution would be to use the normal Cache api to store all of the users current items. That way I could invalidate them when required.
thanks
You can’t get all the current Sessions from all users
(Frankly speaking, you can, but I don’t recommend this, and still you can read only
InProc sessionsthis way).So the only thing you can do is something like this:
SessiononlyIDof the user cartIDto the CacheCache, set the dependency to the ItemCache.Cacheis being emptied – you should provide theCacheItemRemovedCallbackcallback for this event.