修复user扫码登录的redis操作,过期时间设置为30分钟。

This commit is contained in:
junleea 2024-06-12 11:06:15 +08:00
parent 9ed6c4661d
commit c7d3c7a24f
2 changed files with 3 additions and 3 deletions

View File

@ -80,7 +80,7 @@ func ConfirmQRLogin(c *gin.Context) {
if token == "" { if token == "" {
c.JSON(200, gin.H{"code": 20, "message": "Token不存在", "data": "20"}) 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"}) c.JSON(200, gin.H{"code": 0, "message": "success", "data": "0"})
} else { } else {
c.JSON(200, gin.H{"code": 8, "message": "设置Token失败", "data": "8"}) c.JSON(200, gin.H{"code": 8, "message": "设置Token失败", "data": "8"})

View File

@ -52,7 +52,7 @@ func isContainKey(key string) bool {
func SetRedis(key string, value string) bool { func SetRedis(key string, value string) bool {
ctx := context.Background() ctx := context.Background()
// 设置键值对, 0 表示不设置过期时间, 如果需要设置过期时间, 可以设置为 time.Second * 10 等 // 设置键值对, 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 { if err != nil {
fmt.Println("Error setting key: %v", err) fmt.Println("Error setting key: %v", err)
return false return false
@ -93,7 +93,7 @@ func SetHash(key string, data map[string]interface{}) bool {
fmt.Println("%v :Error setting hash: %v", key, err) fmt.Println("%v :Error setting hash: %v", key, err)
return false return false
} }
err = redisClient.Expire(ctx, key, time.Minute*3).Err() err = redisClient.Expire(ctx, key, time.Minute*30).Err()
if err != nil { if err != nil {
fmt.Println("%v :Error setting expire: %v", key, err) fmt.Println("%v :Error setting expire: %v", key, err)
return false return false