fully convert redis over to custom key value store type

This commit is contained in:
Gregory Wells
2026-06-08 18:24:59 -04:00
parent f6016bbdb1
commit 09e0683ae0
5 changed files with 94 additions and 85 deletions
+6 -6
View File
@@ -12,7 +12,7 @@ import (
const SessionCookieName = "session_token"
type SessionManager struct {
store store.Store[string, *SessionData]
store store.KeyValueStore[*SessionData]
}
var instance *SessionManager
@@ -37,12 +37,12 @@ func (manager *SessionManager) SetStoreType(storeType StoreType) {
switch storeType {
case InMemory:
{
manager.store = NewMemoryStore()
// manager.store = NewMemoryStore()
break
}
case Redis:
{
manager.store = NewRedisStore()
manager.store = store.NewRedisStore[*SessionData]()
break
}
}
@@ -72,10 +72,10 @@ func (manager *SessionManager) CreateSession(userID string) (cookie *http.Cookie
Name: SessionCookieName,
Value: token,
Path: "/",
HttpOnly: true, // Essential: prevents JS access
Secure: true, // Set to TRUE in production (HTTPS)
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
MaxAge: 3600, // 1 hour
MaxAge: 3600,
}
return newCookie, nil
}