Update Session of Different Users in ServiceStack

I am new to ServiceStack and I am working on a project that is based on it.

The project has an admin panel, and the administrator can reset user passwords, update information, etc.

The session is stored on Azure Cache Services using the AzureCacheClient provided by ServiceStack.

I want, when the administrator updates some user information, the same update should reflect the IAuthSession caching object. I have access to ICacheClient (of course), but how do I find out the key under which each user session is stored?

+4
source share
1 answer

I have a scenario where I needed to do something like this. My solution was to add the session id associated with the user through CustomUserSession.

Then I use the REDIS client and go through all the sessions until I find it with the user ID, and then I complete all the sessions, perform any update and save the session again.

using (var redis = _appHost.TryResolve<IRedisClientsManager>().GetClient()) { var sessionkeys = redis.SearchKeys("urn:iauthsession:*"); foreach (var key in sessionkeys) { var session = redis.Get<CustomUserSession>(key); if (session != null) { if (session.StudentId == SessionToFindId) { //Perform updates to session redis.Set(key, session); } } } } 
+3
source

Source: https://habr.com/ru/post/1497468/


All Articles