Refactor: remove pkg mem cache

This commit is contained in:
Grail Finder
2025-07-03 14:26:52 +03:00
parent 873c35ab08
commit 9e058b04e0
8 changed files with 60 additions and 228 deletions

View File

@ -6,7 +6,6 @@ import (
"crypto/sha256"
"encoding/base64"
"gralias/models"
"gralias/pkg/cache"
"net/http"
)
@ -71,7 +70,8 @@ func GetSession(next http.Handler) http.Handler {
return
}
if userSession.IsExpired() {
cache.MemCache.RemoveKey(sessionToken)
repo.SessionDelete(r.Context(), sessionToken)
// cache.MemCache.RemoveKey(sessionToken)
msg := "session is expired"
log.Debug(msg, "error", err, "token", sessionToken)
next.ServeHTTP(w, r)
@ -81,13 +81,13 @@ func GetSession(next http.Handler) http.Handler {
models.CtxUsernameKey, userSession.Username)
ctx = context.WithValue(ctx,
models.CtxSessionKey, userSession)
if err := cacheSetSession(sessionToken,
userSession); err != nil {
msg := "failed to marshal user session"
log.Warn(msg, "error", err)
next.ServeHTTP(w, r)
return
}
// if err := cacheSetSession(sessionToken,
// userSession); err != nil {
// msg := "failed to marshal user session"
// log.Warn(msg, "error", err)
// next.ServeHTTP(w, r)
// return
// }
next.ServeHTTP(w, r.WithContext(ctx))
})
}