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