Skip to content

Commit

Permalink
fix(redis_service):修复Redis缓存时间设置问题
Browse files Browse the repository at this point in the history
  • Loading branch information
XiMo-210 committed Jan 26, 2024
1 parent c538324 commit c3823de
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/service/serviceUniFunction.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ func GetUser(prefix string, username string, password string) (*model.User, erro
func SetUser(prefix string, username string, password string, sessionCookie *http.Cookie, routeCookie *http.Cookie) (*model.User, error) {
user := model.User{Username: username, Password: password, Session: *sessionCookie, Route: *routeCookie}
userJson, _ := json.Marshal(user)
config.Redis.Set(getRediskey(prefix, username, password), string(userJson), sessionCookie.Expires.Sub(time.Now().Add(time.Minute*5)))
config.Redis.Set(getRediskey(prefix, username, password), string(userJson), 5*time.Minute)
return &user, nil
}

func ForgetUser(prefix string, username string, password string) {
config.Redis.Del(getRediskey(prefix, username, password))
}

func ForgetAllUser(prefix string) {
res, _ := config.Redis.Keys(prefix + "*").Result()
for _, v := range res {
Expand Down

0 comments on commit c3823de

Please sign in to comment.