修复user扫码登录的redis操作,过期时间设置为30分钟。
This commit is contained in:
parent
9ed6c4661d
commit
c7d3c7a24f
|
|
@ -80,7 +80,7 @@ func ConfirmQRLogin(c *gin.Context) {
|
|||
if token == "" {
|
||||
c.JSON(200, gin.H{"code": 20, "message": "Token不存在", "data": "20"})
|
||||
}
|
||||
if worker.SetRedis(qrsetReq.UUID, token) {
|
||||
if worker.SetHashWithField(qrsetReq.UUID, "status", token) {
|
||||
c.JSON(200, gin.H{"code": 0, "message": "success", "data": "0"})
|
||||
} else {
|
||||
c.JSON(200, gin.H{"code": 8, "message": "设置Token失败", "data": "8"})
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func isContainKey(key string) bool {
|
|||
func SetRedis(key string, value string) bool {
|
||||
ctx := context.Background()
|
||||
// 设置键值对, 0 表示不设置过期时间, 如果需要设置过期时间, 可以设置为 time.Second * 10 等
|
||||
err := redisClient.Set(ctx, key, value, time.Second*100).Err()
|
||||
err := redisClient.Set(ctx, key, value, time.Minute*30).Err()
|
||||
if err != nil {
|
||||
fmt.Println("Error setting key: %v", err)
|
||||
return false
|
||||
|
|
@ -93,7 +93,7 @@ func SetHash(key string, data map[string]interface{}) bool {
|
|||
fmt.Println("%v :Error setting hash: %v", key, err)
|
||||
return false
|
||||
}
|
||||
err = redisClient.Expire(ctx, key, time.Minute*3).Err()
|
||||
err = redisClient.Expire(ctx, key, time.Minute*30).Err()
|
||||
if err != nil {
|
||||
fmt.Println("%v :Error setting expire: %v", key, err)
|
||||
return false
|
||||
|
|
|
|||
Loading…
Reference in New Issue