This commit is contained in:
wangchuxiao 2023-03-27 17:20:36 +08:00
parent cfb157d2e4
commit cb26321847
13 changed files with 23 additions and 18 deletions

2
go.mod
View File

@ -35,7 +35,7 @@ require (
golang.org/x/image v0.3.0
google.golang.org/api v0.103.0
google.golang.org/grpc v1.52.3
google.golang.org/protobuf v1.28.1
google.golang.org/protobuf v1.30.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.3.5
gorm.io/gorm v1.23.8

3
go.sum
View File

@ -1349,8 +1349,9 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -23,7 +23,7 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (
cbReq := &callbackstruct.CallbackBeforeCreateGroupReq{
CallbackCommand: constant.CallbackBeforeCreateGroupCommand,
OperationID: mcontext.GetOperationID(ctx),
GroupInfo: *req.GroupInfo,
GroupInfo: req.GroupInfo,
}
cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{
UserID: req.OwnerUserID,

View File

@ -14,7 +14,7 @@ func (c CallbackCommand) GetCallbackCommand() string {
type CallbackBeforeCreateGroupReq struct {
OperationID string `json:"operationID"`
CallbackCommand `json:"callbackCommand"`
common.GroupInfo
*common.GroupInfo
InitMemberList []*apistruct.GroupAddMemberInfo `json:"initMemberList"`
}

View File

@ -46,7 +46,7 @@ func (b *BlackCacheRedis) NewCache() BlackCache {
expireTime: b.expireTime,
rcClient: b.rcClient,
blackDB: b.blackDB,
metaCache: NewMetaCacheRedis(b.rcClient, b.metaCache.GetPreDeleteKeys()...),
metaCache: NewMetaCacheRedis(b.rcClient, b.metaCache.GetPreDelKeys()...),
}
}

View File

@ -68,7 +68,7 @@ func NewNewConversationRedis(rdb redis.UniversalClient, conversationDB *relation
}
func (c *ConversationRedisCache) NewCache() ConversationCache {
return &ConversationRedisCache{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDeleteKeys()...), conversationDB: c.conversationDB, expireTime: c.expireTime}
return &ConversationRedisCache{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...), conversationDB: c.conversationDB, expireTime: c.expireTime}
}
func (c *ConversationRedisCache) getConversationKey(ownerUserID, conversationID string) string {

View File

@ -40,7 +40,7 @@ func NewExtendMsgSetCacheRedis(rdb redis.UniversalClient, extendMsgSetDB unrelat
func (e *ExtendMsgSetCacheRedis) NewCache() ExtendMsgSetCache {
return &ExtendMsgSetCacheRedis{
metaCache: NewMetaCacheRedis(e.rcClient, e.metaCache.GetPreDeleteKeys()...),
metaCache: NewMetaCacheRedis(e.rcClient, e.metaCache.GetPreDelKeys()...),
expireTime: e.expireTime,
extendMsgSetDB: e.extendMsgSetDB,
rcClient: e.rcClient,

View File

@ -48,7 +48,7 @@ func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationTb.FriendMo
}
func (c *FriendCacheRedis) NewCache() FriendCache {
return &FriendCacheRedis{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDeleteKeys()...), friendDB: c.friendDB, expireTime: c.expireTime}
return &FriendCacheRedis{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...), friendDB: c.friendDB, expireTime: c.expireTime}
}
func (f *FriendCacheRedis) getFriendIDsKey(ownerUserID string) string {

View File

@ -74,7 +74,7 @@ func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB relationTb.GroupModel
}
func (g *GroupCacheRedis) NewCache() GroupCache {
return &GroupCacheRedis{rcClient: g.rcClient, expireTime: g.expireTime, groupDB: g.groupDB, groupMemberDB: g.groupMemberDB, groupRequestDB: g.groupRequestDB, mongoDB: g.mongoDB, metaCache: NewMetaCacheRedis(g.rcClient, g.metaCache.GetPreDeleteKeys()...)}
return &GroupCacheRedis{rcClient: g.rcClient, expireTime: g.expireTime, groupDB: g.groupDB, groupMemberDB: g.groupMemberDB, groupRequestDB: g.groupRequestDB, mongoDB: g.mongoDB, metaCache: NewMetaCacheRedis(g.rcClient, g.metaCache.GetPreDelKeys()...)}
}
func (g *GroupCacheRedis) getGroupInfoKey(groupID string) string {

View File

@ -21,7 +21,8 @@ type metaCache interface {
// delete key rapid
DelKey(ctx context.Context, key string) error
AddKeys(keys ...string)
GetPreDeleteKeys() []string
ClearKeys()
GetPreDelKeys() []string
}
func NewMetaCacheRedis(rcClient *rockscache.Client, keys ...string) metaCache {
@ -49,7 +50,11 @@ func (m *metaCacheRedis) AddKeys(keys ...string) {
m.keys = append(m.keys, keys...)
}
func (m *metaCacheRedis) GetPreDeleteKeys() []string {
func (m *metaCacheRedis) ClearKeys() {
m.keys = []string{}
}
func (m *metaCacheRedis) GetPreDelKeys() []string {
return m.keys
}

View File

@ -44,7 +44,7 @@ func NewUserCacheRedis(rdb redis.UniversalClient, userDB relationTb.UserModelInt
func (u *UserCacheRedis) NewCache() UserCache {
return &UserCacheRedis{
metaCache: NewMetaCacheRedis(u.rcClient, u.metaCache.GetPreDeleteKeys()...),
metaCache: NewMetaCacheRedis(u.rcClient, u.metaCache.GetPreDelKeys()...),
userDB: u.userDB,
expireTime: u.expireTime,
rcClient: u.rcClient,

View File

@ -75,10 +75,10 @@ func (c *ConversationDataBase) SetUsersConversationFiledTx(ctx context.Context,
return err
}
cache = cache.DelConversationIDs(NotUserIDs)
log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDeleteKeys(), "addr", &cache)
log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDelKeys(), "addr", &cache)
}
// clear cache
log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDeleteKeys(), "addr", &cache)
log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDelKeys(), "addr", &cache)
return cache.DelUsersConversation(haveUserIDs, conversation.ConversationID).ExecDel(ctx)
})
}

View File

@ -2,14 +2,15 @@ package utils
import (
"errors"
"github.com/nfnt/resize"
"golang.org/x/image/bmp"
"image"
"image/gif"
"image/jpeg"
"image/png"
"io"
"os"
"github.com/nfnt/resize"
"golang.org/x/image/bmp"
)
func GenSmallImage(src, dst string) error {
@ -51,6 +52,4 @@ func scale(in io.Reader, out io.Writer, width, height, quality int) error {
default:
return errors.New("ERROR FORMAT")
}
return nil
}