mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
redis add func
This commit is contained in:
parent
d50a0abd2a
commit
7da98935b9
@ -109,7 +109,16 @@ func (d *DataBases) SetMultiConversationMsgOpt(userID string, m map[string]int)
|
||||
_, err := d.Exec("hmset", key, redis.Args{}.Add().AddFlat(m)...)
|
||||
return err
|
||||
}
|
||||
func (d *DataBases) GetMultiConversationMsgOpt(userID string, conversationIDs []string) ([]int, error) {
|
||||
func (d *DataBases) GetMultiConversationMsgOpt(userID string, conversationIDs []string) (m map[string]int, err error) {
|
||||
m = make(map[string]int)
|
||||
key := conversationReceiveMessageOpt + userID
|
||||
return redis.Ints(d.Exec("hmget", key, redis.Args{}.Add().AddFlat(conversationIDs)...))
|
||||
i, err := redis.Ints(d.Exec("hmget", key, redis.Args{}.Add().AddFlat(conversationIDs)...))
|
||||
if err != nil {
|
||||
return m, err
|
||||
}
|
||||
for k, v := range conversationIDs {
|
||||
m[v] = i[k]
|
||||
}
|
||||
return m, nil
|
||||
|
||||
}
|
||||
|
@ -19,3 +19,9 @@ func Test_GetTokenMapByUidPid(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
fmt.Println(m)
|
||||
}
|
||||
|
||||
func TestDataBases_GetMultiConversationMsgOpt(t *testing.T) {
|
||||
m, err := DB.GetMultiConversationMsgOpt("fg", []string{"user", "age", "color"})
|
||||
assert.Nil(t, err)
|
||||
fmt.Println(m)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user