pull/232/head
wangchuxiao 3 years ago
parent 9dfef527a3
commit c32b53b3c0

@ -227,6 +227,8 @@ multiloginpolicy: 1
chatpersistencemysql: true chatpersistencemysql: true
#可靠性存储 #可靠性存储
reliablestorage: false reliablestorage: false
#消息缓存时间
msgCacheTimeout: 60 * 60
#token config #token config
tokenpolicy: tokenpolicy:

@ -218,6 +218,7 @@ type config struct {
MultiLoginPolicy int `yaml:"multiloginpolicy"` MultiLoginPolicy int `yaml:"multiloginpolicy"`
ChatPersistenceMysql bool `yaml:"chatpersistencemysql"` ChatPersistenceMysql bool `yaml:"chatpersistencemysql"`
ReliableStorage bool `yaml:"reliablestorage"` ReliableStorage bool `yaml:"reliablestorage"`
MsgCacheTimeout int `yaml:"msgCacheTimeout"`
TokenPolicy struct { TokenPolicy struct {
AccessSecret string `yaml:"accessSecret"` AccessSecret string `yaml:"accessSecret"`

@ -1,6 +1,7 @@
package db package db
import ( import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
log2 "Open_IM/pkg/common/log" log2 "Open_IM/pkg/common/log"
pbChat "Open_IM/pkg/proto/chat" pbChat "Open_IM/pkg/proto/chat"
@ -274,7 +275,7 @@ func (d *DataBases) SetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid string)
continue continue
} }
log2.NewDebug("", "m", m) log2.NewDebug("", "m", m)
_, err = d.Exec("hmset", key, redis.Args{}.Add().AddFlat(m)...) _, err = d.Exec("hmset", key, redis.Args{}.Add("TIMEOUT", config.Config.MsgCacheTimeout).AddFlat(m)...)
if err != nil { if err != nil {
log2.NewWarn("", utils.GetSelfFuncName(), "redis failed", "args:", key, *msg, uid, m) log2.NewWarn("", utils.GetSelfFuncName(), "redis failed", "args:", key, *msg, uid, m)
failedList = append(failedList, *msg) failedList = append(failedList, *msg)

Loading…
Cancel
Save