mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-15 06:25:58 +08:00
cache
This commit is contained in:
@@ -32,3 +32,21 @@ type GetSelfUserInfoResp struct {
|
||||
UserInfo *open_im_sdk.UserInfo `json:"-"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type GetFriendIDListFromCacheReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetFriendIDListFromCacheResp struct {
|
||||
CommResp
|
||||
UserIDList []string `json:"userIDList" binding:"required"`
|
||||
}
|
||||
|
||||
type GetBlackIDListFromCacheReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetBlackIDListFromCacheResp struct {
|
||||
CommResp
|
||||
UserIDList []string `json:"userIDList" binding:"required"`
|
||||
}
|
||||
|
||||
@@ -165,13 +165,8 @@ func (d *DataBases) SearchContentType() {
|
||||
|
||||
}
|
||||
|
||||
func (d *DataBases) SetUserInfoToCache(userInfo *pbCommon.UserInfo) error {
|
||||
b, _ := json.Marshal(&userInfo)
|
||||
m := map[string]interface{}{}
|
||||
if err := json.Unmarshal(b, &m); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := d.Exec("hmset", userInfoCache+userInfo.UserID, redis.Args{}.Add().AddFlat(m)...)
|
||||
func (d *DataBases) SetUserInfoToCache(userID string, m map[string]interface{}) error {
|
||||
_, err := d.Exec("hmset", userInfoCache+userID, redis.Args{}.Add().AddFlat(m)...)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +154,3 @@ func UserDBCopyOpenIM(dst *open_im_sdk.UserInfo, src *db.User) {
|
||||
func UserDBCopyOpenIMPublicUser(dst *open_im_sdk.PublicUserInfo, src *db.User) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
//
|
||||
//func PublicUserDBCopyOpenIM(dst *open_im_sdk.PublicUserInfo, src *db.User){
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/gogo/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/pkg/errors"
|
||||
"math/rand"
|
||||
@@ -131,3 +135,18 @@ func RemoveRepeatedStringInList(slc []string) []string {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func Pb2Map(pb proto.Message) (map[string]interface{}, error) {
|
||||
_buffer := bytes.Buffer{}
|
||||
jsonbMarshaller := &jsonpb.Marshaler{
|
||||
OrigName: true,
|
||||
EnumsAsInts: true,
|
||||
EmitDefaults: true,
|
||||
}
|
||||
_ = jsonbMarshaller.Marshal(&_buffer, pb)
|
||||
jsonCnt := _buffer.Bytes()
|
||||
var out map[string]interface{}
|
||||
err := json.Unmarshal(jsonCnt, &out)
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user