用户中心
This commit is contained in:
parent
8a55bfc82b
commit
4ecdda9468
|
|
@ -410,11 +410,12 @@ func GetUserByIDFromUserCenter(id int) dao.User {
|
|||
var user dao.User
|
||||
//先从redis获取
|
||||
key := "user_info_" + strconv.Itoa(id)
|
||||
user_str := worker.GetRedis(key)
|
||||
if user_str != "" {
|
||||
err := json.Unmarshal([]byte(user_str), &user)
|
||||
userStr := worker.GetRedis(key)
|
||||
log.Println("user_str:", userStr)
|
||||
if userStr != "" {
|
||||
err := json.Unmarshal([]byte(userStr), &user)
|
||||
if err != nil {
|
||||
fmt.Println("get user info , json unmarshal error:", err, "\tuser_str:", user_str)
|
||||
fmt.Println("get user info , json unmarshal error:", err, "\tuser_str:", userStr)
|
||||
return dao.User{}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -425,14 +426,16 @@ func GetUserByIDFromUserCenter(id int) dao.User {
|
|||
fmt.Println("get user info , json marshal error:", err)
|
||||
return dao.User{}
|
||||
}
|
||||
user_str = string(userJson)
|
||||
success := worker.SetRedisWithExpire(key, user_str, time.Second*10)
|
||||
userStr = string(userJson)
|
||||
success := worker.SetRedisWithExpire(key, userStr, time.Second*10)
|
||||
if !success {
|
||||
fmt.Println("set redis error,user json:", user_str)
|
||||
fmt.Println("set redis error,user json:", userStr)
|
||||
}
|
||||
} else {
|
||||
log.Println("GetUserByIDFromUserCenter user not found, id:", id)
|
||||
log.Println("response user:", user)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Println("user_str:", user_str)
|
||||
return user
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue