修复im消息获取key,删除redis queue错误信息输出
This commit is contained in:
parent
3d1b22487c
commit
f760b7a73f
|
|
@ -66,13 +66,17 @@ func GetImKey(c *gin.Context) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
retrievedData["is_read"] = 1
|
retrievedData["is_read"] = 1
|
||||||
res2 := worker.SetRedisWithExpire(redis_key+"_connection", retrievedData["im_session"].(string), time.Second*30)
|
str, _ := json.Marshal(retrievedData)
|
||||||
if res2 == false {
|
res3 := worker.SetRedisWithExpire(redis_key, string(str), time.Second*300)
|
||||||
|
res2 := worker.SetRedisWithExpire(redis_key+"_connection", retrievedData["im_session"].(string), time.Second*300)
|
||||||
|
if res2 == false || res3 == false {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": "set key failed", "code": proto.OperationFailed, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": "set key failed", "code": proto.OperationFailed, "message": "failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "data": retrievedData, "message": "success"})
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "data": retrievedData, "message": "success"})
|
||||||
return
|
return
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "data": retrievedData, "message": "success"})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +96,7 @@ func GetImKey(c *gin.Context) {
|
||||||
data["is_read"] = 0
|
data["is_read"] = 0
|
||||||
str, _ := json.Marshal(data)
|
str, _ := json.Marshal(data)
|
||||||
//将key存入redis
|
//将key存入redis
|
||||||
res := worker.SetRedisWithExpire(redis_key, string(str), time.Second*30)
|
res := worker.SetRedisWithExpire(redis_key, string(str), time.Second*300)
|
||||||
if res == false {
|
if res == false {
|
||||||
c.JSON(http.StatusOK, gin.H{"error": "set key failed", "code": proto.OperationFailed, "message": "failed"})
|
c.JSON(http.StatusOK, gin.H{"error": "set key failed", "code": proto.OperationFailed, "message": "failed"})
|
||||||
return
|
return
|
||||||
|
|
@ -176,7 +180,7 @@ func SRMessage(c *gin.Context) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
time.Sleep(time.Microsecond * 100) // 每100毫秒查询一次
|
time.Sleep(time.Second * 1) // 每100毫秒查询一次
|
||||||
} else {
|
} else {
|
||||||
clientsMux.Lock()
|
clientsMux.Lock()
|
||||||
delete(clients, ws)
|
delete(clients, ws)
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,6 @@ func PopRedisListLeft(key string) string {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
val, err := redisClient.LPop(ctx, key).Result() // 从 Redis 读取键值, 如果键不存在则返回空字符串, 如果出现错误则返回错误
|
val, err := redisClient.LPop(ctx, key).Result() // 从 Redis 读取键值, 如果键不存在则返回空字符串, 如果出现错误则返回错误
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(key, " Error reading from Redis: %v", err)
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue