group complete

This commit is contained in:
withchao
2023-02-08 20:08:22 +08:00
parent b3ae69ce94
commit f20e9e71b7
15 changed files with 544 additions and 864 deletions
+3 -1
View File
@@ -22,6 +22,8 @@ type ConversationCache interface {
GetConversationsFromCache(ownerUserID string, conversationIDList []string, fn DBFun) ([]*table.ConversationModel, error)
GetUserAllConversationList(ownerUserID string, fn DBFun) ([]*table.ConversationModel, error)
DelConversationFromCache(ownerUserID, conversationID string) error
GetUserConversationIDs(ctx context.Context, ownerUserID string, f func(ctx context.Context, userID string) ([]string, error)) ([]string, error)
}
type ConversationRedis struct {
rcClient *rockscache.Client
@@ -51,7 +53,7 @@ func (c *ConversationCache) getSuperGroupRecvNotNotifyUserIDsKey(groupID string)
return superGroupRecvMsgNotNotifyUserIDsKey + groupID
}
func (c *ConversationCache) GetUserConversationIDs(ctx context.Context, ownerUserID string, f func(userID string) ([]string, error)) (conversationIDs []string, err error) {
func (c *ConversationCache) GetUserConversationIDs(ctx context.Context, ownerUserID string, f func(ctx context.Context, userID string) ([]string, error)) (conversationIDs []string, err error) {
//getConversationIDs := func() (string, error) {
// conversationIDs, err := relation.GetConversationIDsByUserID(ownerUserID)
// if err != nil {
+5 -6
View File
@@ -2,8 +2,8 @@ package cache
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db/localcache"
"Open_IM/pkg/common/db/relation"
relation2 "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/common/db/unrelation"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
@@ -14,7 +14,6 @@ import (
"math/big"
"sort"
"strconv"
"sync"
"time"
)
@@ -30,16 +29,16 @@ const (
)
type GroupCache struct {
group *relation.GroupGorm
groupMember *relation.GroupMemberGorm
groupRequest *relation.GroupRequestGorm
group relation2.GroupModelInterface
groupMember relation2.GroupMemberModelInterface
groupRequest relation2.GroupRequestModelInterface
mongoDB *unrelation.SuperGroupMongoDriver
expireTime time.Duration
redisClient *RedisClient
rcClient *rockscache.Client
}
func NewGroupCache(rdb redis.UniversalClient, groupDB *relation.GroupGorm, groupMemberDB *relation.GroupMemberGorm, groupRequestDB *relation.GroupRequestGorm, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCache {
func NewGroupCache(rdb redis.UniversalClient, groupDB relation2.GroupModelInterface, groupMemberDB relation2.GroupMemberModelInterface, groupRequestDB relation2.GroupRequestModelInterface, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCache {
return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
mongoDB: mongoClient,