Refactor: remove pkg mem cache
This commit is contained in:
		| @@ -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)) | ||||
| 	}) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder