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
The standard mechanism for tracking sessions is a cookie. Clearing your browser's cache, and therefore your cookies as well, will result in no session ID being sent to the server when a request is made, so it has no choice but to begin a new session.
It's possible to use Redis Enterprise as both a cache and a session store in a single setup, as shown in the picture below. In this design, the application layer accesses and maintains the data in the cache. Therefore, all the sessions running inside the application access the same data stored in the cache.
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 sessions
this way).
So the only thing you can do is something like this:
Session
only ID
of the user cartID
to the CacheCache
, set the dependency to the Item
Cache
.Cache
is being emptied - you should provide the CacheItemRemovedCallback
callback for this event.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With