diff options
author | vnugent <public@vaughnnugent.com> | 2023-08-01 18:39:13 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-08-01 18:39:13 -0400 |
commit | 67773b085cac372dc6cc63bc9b5d1292c650d071 (patch) | |
tree | 682e605dc52026f7a5e80b32a8ac06066ee14c41 /libs/VNLib.Plugins.Sessions.VNCache | |
parent | effb0538dbe26553992b883472df5bba4f46a4d3 (diff) |
Latest updates, build configurations, and native compression
Diffstat (limited to 'libs/VNLib.Plugins.Sessions.VNCache')
-rw-r--r-- | libs/VNLib.Plugins.Sessions.VNCache/src/WebSessionStore.cs | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/libs/VNLib.Plugins.Sessions.VNCache/src/WebSessionStore.cs b/libs/VNLib.Plugins.Sessions.VNCache/src/WebSessionStore.cs index 12644e1..c0b1e5d 100644 --- a/libs/VNLib.Plugins.Sessions.VNCache/src/WebSessionStore.cs +++ b/libs/VNLib.Plugins.Sessions.VNCache/src/WebSessionStore.cs @@ -97,28 +97,8 @@ namespace VNLib.Plugins.Sessions.VNCache //Run delete/cleanup Task delete = DeleteSessionAsync(session); - //Regenid and create new session - string newId = IdFactory.RegenerateId(entity); - - //Get new session empty session for the connection - WebSession newSession = SessionFactory.GetNewSession(entity, newId, null); - - //Reset security information for new session - newSession.InitNewSession(entity.Server); - - IDictionary<string, string> data = newSession.GetSessionData(); - - //commit session to cache - Task add = Cache.AddOrUpdateObjectAsync(newId, null, data); - - /* - * Call complete on session for good practice, this SHOULD be - * called after the update has been awaited though. - * - * We also do not need to use the mutal exclusion mechanism because - * no other connections should have this session's id yet. - */ - newSession.SessionUpdateComplete(); + //Create new session for the same connection + Task add = CreateNewSession(entity); //Await the invalidation async return new(AwaitInvalidate(delete, add)); @@ -129,6 +109,34 @@ namespace VNLib.Plugins.Sessions.VNCache } } + private Task CreateNewSession(IHttpEvent entity) + { + //Regenid and create new session + string newId = IdFactory.RegenerateId(entity); + + //Get new session empty session for the connection + WebSession newSession = SessionFactory.GetNewSession(entity, newId, null); + + //Reset security information for new session + newSession.InitNewSession(entity.Server); + + IDictionary<string, string> data = newSession.GetSessionData(); + + //commit session to cache + Task add = Cache.AddOrUpdateObjectAsync(newId, null, data); + + /* + * Call complete on session for good practice, this SHOULD be + * called after the update has been awaited though. + * + * We also do not need to use the mutual exclusion mechanism because + * no other connections should have this session's id yet. + */ + newSession.SessionUpdateComplete(); + + return add; + } + private static async Task AwaitInvalidate(Task delete, Task addNew) { try |