cache

package
v3.5.1-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FCM_TOKEN = "FCM_TOKEN:"
)
View Source
const (
	TwoWayFriendsIDsKey = "COMMON_FRIENDS_IDS:"
)

Variables

This section is empty.

Functions

func GetDefaultOpt

func GetDefaultOpt() rockscache.Options

func NewMetaCacheRedis

func NewMetaCacheRedis(rcClient *rockscache.Client, keys ...string) metaCache

func NewRedis

func NewRedis() (redis.UniversalClient, error)

NewRedis Initialize redis connection.

func RemoveRepeatedElementsInList added in v3.4.0

func RemoveRepeatedElementsInList[T Comparable](slc []T) []T

Types

type BlackCache

type BlackCache interface {
	NewCache() BlackCache
	GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error)
	// del user's blackIDs msgCache, exec when a user's black list changed
	DelBlackIDs(ctx context.Context, userID string) BlackCache
	// contains filtered or unexported methods
}

args fn will exec when no data in msgCache.

func NewBlackCacheRedis

func NewBlackCacheRedis(
	rdb redis.UniversalClient,
	blackDB relationtb.BlackModelInterface,
	options rockscache.Options,
) BlackCache

type BlackCacheRedis

type BlackCacheRedis struct {
	// contains filtered or unexported fields
}

func (*BlackCacheRedis) DelBlackIDs

func (b *BlackCacheRedis) DelBlackIDs(ctx context.Context, userID string) BlackCache

func (*BlackCacheRedis) GetBlackIDs

func (b *BlackCacheRedis) GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error)

func (*BlackCacheRedis) NewCache

func (b *BlackCacheRedis) NewCache() BlackCache

type Comparable added in v3.4.0

type Comparable interface {
	~int | ~string | ~float64 | ~int32
}

type ConversationCache

type ConversationCache interface {
	NewCache() ConversationCache
	// get user's conversationIDs from msgCache
	GetUserConversationIDs(ctx context.Context, ownerUserID string) ([]string, error)
	DelConversationIDs(userIDs ...string) ConversationCache

	GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
	DelUserConversationIDsHash(ownerUserIDs ...string) ConversationCache

	// get one conversation from msgCache
	GetConversation(ctx context.Context, ownerUserID, conversationID string) (*relationtb.ConversationModel, error)
	DelConversations(ownerUserID string, conversationIDs ...string) ConversationCache
	DelUsersConversation(conversationID string, ownerUserIDs ...string) ConversationCache
	// get one conversation from msgCache
	GetConversations(ctx context.Context, ownerUserID string,
		conversationIDs []string) ([]*relationtb.ConversationModel, error)
	// get one user's all conversations from msgCache
	GetUserAllConversations(ctx context.Context, ownerUserID string) ([]*relationtb.ConversationModel, error)
	// get user conversation recv msg from msgCache
	GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
	DelUserRecvMsgOpt(ownerUserID, conversationID string) ConversationCache
	// get one super group recv msg but do not notification userID list
	//GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (userIDs []string, err error)
	DelSuperGroupRecvMsgNotNotifyUserIDs(groupID string) ConversationCache
	// get one super group recv msg but do not notification userID list hash
	//GetSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) (hash uint64, err error)
	DelSuperGroupRecvMsgNotNotifyUserIDsHash(groupID string) ConversationCache

	//GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error)
	DelUserAllHasReadSeqs(ownerUserID string, conversationIDs ...string) ConversationCache

	GetConversationsByConversationID(ctx context.Context,
		conversationIDs []string) ([]*relationtb.ConversationModel, error)
	DelConversationByConversationID(conversationIDs ...string) ConversationCache
	GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error)
	DelConversationNotReceiveMessageUserIDs(conversationIDs ...string) ConversationCache
	// contains filtered or unexported methods
}

arg fn will exec when no data in msgCache.

func NewConversationRedis

func NewConversationRedis(rdb redis.UniversalClient, opts rockscache.Options, db relationtb.ConversationModelInterface) ConversationCache

type ConversationRedisCache

type ConversationRedisCache struct {
	// contains filtered or unexported fields
}

func (*ConversationRedisCache) DelConversationByConversationID

func (c *ConversationRedisCache) DelConversationByConversationID(conversationIDs ...string) ConversationCache

func (*ConversationRedisCache) DelConversationIDs

func (c *ConversationRedisCache) DelConversationIDs(userIDs ...string) ConversationCache

func (*ConversationRedisCache) DelConversationNotReceiveMessageUserIDs added in v3.3.2

func (c *ConversationRedisCache) DelConversationNotReceiveMessageUserIDs(conversationIDs ...string) ConversationCache

func (*ConversationRedisCache) DelConversations

func (c *ConversationRedisCache) DelConversations(ownerUserID string, conversationIDs ...string) ConversationCache

func (*ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDs

func (c *ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDs(groupID string) ConversationCache

func (*ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash

func (c *ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash(groupID string) ConversationCache

func (*ConversationRedisCache) DelUserAllHasReadSeqs

func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, conversationIDs ...string) ConversationCache

func (*ConversationRedisCache) DelUserConversationIDsHash

func (c *ConversationRedisCache) DelUserConversationIDsHash(ownerUserIDs ...string) ConversationCache

func (*ConversationRedisCache) DelUserRecvMsgOpt

func (c *ConversationRedisCache) DelUserRecvMsgOpt(ownerUserID, conversationID string) ConversationCache

func (*ConversationRedisCache) DelUsersConversation

func (c *ConversationRedisCache) DelUsersConversation(conversationID string, ownerUserIDs ...string) ConversationCache

func (*ConversationRedisCache) GetConversation

func (c *ConversationRedisCache) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*relationtb.ConversationModel, error)

func (*ConversationRedisCache) GetConversationNotReceiveMessageUserIDs added in v3.3.2

func (c *ConversationRedisCache) GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error)

func (*ConversationRedisCache) GetConversations

func (c *ConversationRedisCache) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationtb.ConversationModel, error)

func (*ConversationRedisCache) GetConversationsByConversationID

func (c *ConversationRedisCache) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationtb.ConversationModel, error)

func (*ConversationRedisCache) GetUserAllConversations

func (c *ConversationRedisCache) GetUserAllConversations(ctx context.Context, ownerUserID string) ([]*relationtb.ConversationModel, error)

func (*ConversationRedisCache) GetUserConversationIDs

func (c *ConversationRedisCache) GetUserConversationIDs(ctx context.Context, ownerUserID string) ([]string, error)

func (*ConversationRedisCache) GetUserConversationIDsHash

func (c *ConversationRedisCache) GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)

func (*ConversationRedisCache) GetUserRecvMsgOpt

func (c *ConversationRedisCache) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)

func (*ConversationRedisCache) NewCache

type FriendCache

type FriendCache interface {
	NewCache() FriendCache
	GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error)
	// Called when friendID list changed
	DelFriendIDs(ownerUserID ...string) FriendCache
	// Get single friendInfo from the cache
	GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relationtb.FriendModel, err error)
	// Delete friend when friend info changed
	DelFriend(ownerUserID, friendUserID string) FriendCache
	// Delete friends when friends' info changed
	DelFriends(ownerUserID string, friendUserIDs []string) FriendCache
	// contains filtered or unexported methods
}

FriendCache is an interface for caching friend-related data.

func NewFriendCacheRedis

func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationtb.FriendModelInterface,
	options rockscache.Options) FriendCache

NewFriendCacheRedis creates a new instance of FriendCacheRedis.

type FriendCacheRedis

type FriendCacheRedis struct {
	// contains filtered or unexported fields
}

FriendCacheRedis is an implementation of the FriendCache interface using Redis.

func (*FriendCacheRedis) DelFriend

func (f *FriendCacheRedis) DelFriend(ownerUserID, friendUserID string) FriendCache

DelFriend deletes friend info from the cache.

func (*FriendCacheRedis) DelFriendIDs

func (f *FriendCacheRedis) DelFriendIDs(ownerUserIDs ...string) FriendCache

DelFriendIDs deletes friend IDs from the cache.

func (*FriendCacheRedis) DelFriends added in v3.6.0

func (f *FriendCacheRedis) DelFriends(ownerUserID string, friendUserIDs []string) FriendCache

DelFriends deletes multiple friend infos from the cache.

func (*FriendCacheRedis) DelTwoWayFriendIDs

func (f *FriendCacheRedis) DelTwoWayFriendIDs(ctx context.Context, ownerUserID string) FriendCache

DelTwoWayFriendIDs deletes two-way friend IDs from the cache.

func (*FriendCacheRedis) GetFriend

func (f *FriendCacheRedis) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relationtb.FriendModel, err error)

GetFriend retrieves friend info from the cache or the database if not found.

func (*FriendCacheRedis) GetFriendIDs

func (f *FriendCacheRedis) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error)

GetFriendIDs retrieves friend IDs from the cache or the database if not found.

func (*FriendCacheRedis) GetTwoWayFriendIDs

func (f *FriendCacheRedis) GetTwoWayFriendIDs(ctx context.Context, ownerUserID string) (twoWayFriendIDs []string, err error)

GetTwoWayFriendIDs retrieves two-way friend IDs from the cache.

func (*FriendCacheRedis) NewCache

func (f *FriendCacheRedis) NewCache() FriendCache

NewCache creates a new instance of FriendCacheRedis with the same configuration.

type GroupCache

type GroupCache interface {
	NewCache() GroupCache
	GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
	GetGroupInfo(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)
	DelGroupsInfo(groupIDs ...string) GroupCache

	GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error)
	GetGroupMemberHashMap(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error)
	DelGroupMembersHash(groupID string) GroupCache

	GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error)
	GetGroupsMemberIDs(ctx context.Context, groupIDs []string) (groupMemberIDs map[string][]string, err error)

	DelGroupMemberIDs(groupID string) GroupCache

	GetJoinedGroupIDs(ctx context.Context, userID string) (joinedGroupIDs []string, err error)
	DelJoinedGroupID(userID ...string) GroupCache

	GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relationtb.GroupMemberModel, err error)
	GetGroupMembersInfo(ctx context.Context, groupID string, userID []string) (groupMembers []*relationtb.GroupMemberModel, err error)
	GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationtb.GroupMemberModel, err error)
	GetGroupMembersPage(ctx context.Context, groupID string, userID []string, showNumber, pageNumber int32) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error)
	FindGroupMemberUser(ctx context.Context, groupIDs []string, userID string) ([]*relationtb.GroupMemberModel, error)

	GetGroupRoleLevelMemberIDs(ctx context.Context, groupID string, roleLevel int32) ([]string, error)
	GetGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error)
	GetGroupsOwner(ctx context.Context, groupIDs []string) ([]*relationtb.GroupMemberModel, error)
	DelGroupRoleLevel(groupID string, roleLevel []int32) GroupCache
	DelGroupAllRoleLevel(groupID string) GroupCache
	DelGroupMembersInfo(groupID string, userID ...string) GroupCache
	GetGroupRoleLevelMemberInfo(ctx context.Context, groupID string, roleLevel int32) ([]*relationtb.GroupMemberModel, error)
	GetGroupRolesLevelMemberInfo(ctx context.Context, groupID string, roleLevels []int32) ([]*relationtb.GroupMemberModel, error)
	GetGroupMemberNum(ctx context.Context, groupID string) (memberNum int64, err error)
	DelGroupsMemberNum(groupID ...string) GroupCache
	// contains filtered or unexported methods
}

func NewGroupCacheRedis

func NewGroupCacheRedis(
	rdb redis.UniversalClient,
	groupDB relationtb.GroupModelInterface,
	groupMemberDB relationtb.GroupMemberModelInterface,
	groupRequestDB relationtb.GroupRequestModelInterface,
	hashCode GroupHash,
	opts rockscache.Options,
) GroupCache

type GroupCacheRedis

type GroupCacheRedis struct {
	// contains filtered or unexported fields
}

func (*GroupCacheRedis) DelGroupAllRoleLevel added in v3.4.2

func (g *GroupCacheRedis) DelGroupAllRoleLevel(groupID string) GroupCache

func (*GroupCacheRedis) DelGroupMemberIDs

func (g *GroupCacheRedis) DelGroupMemberIDs(groupID string) GroupCache

func (*GroupCacheRedis) DelGroupMembersHash

func (g *GroupCacheRedis) DelGroupMembersHash(groupID string) GroupCache

func (*GroupCacheRedis) DelGroupMembersInfo

func (g *GroupCacheRedis) DelGroupMembersInfo(groupID string, userIDs ...string) GroupCache

func (*GroupCacheRedis) DelGroupRoleLevel added in v3.4.2

func (g *GroupCacheRedis) DelGroupRoleLevel(groupID string, roleLevels []int32) GroupCache

func (*GroupCacheRedis) DelGroupsInfo

func (g *GroupCacheRedis) DelGroupsInfo(groupIDs ...string) GroupCache

func (*GroupCacheRedis) DelGroupsMemberNum

func (g *GroupCacheRedis) DelGroupsMemberNum(groupID ...string) GroupCache

func (*GroupCacheRedis) DelGroupsOwner added in v3.4.2

func (g *GroupCacheRedis) DelGroupsOwner(groupIDs ...string) GroupCache

func (*GroupCacheRedis) DelJoinedGroupID

func (g *GroupCacheRedis) DelJoinedGroupID(userIDs ...string) GroupCache

func (*GroupCacheRedis) FindGroupMemberUser added in v3.4.2

func (g *GroupCacheRedis) FindGroupMemberUser(ctx context.Context, groupIDs []string, userID string) (_ []*relationtb.GroupMemberModel, err error)

func (*GroupCacheRedis) GetAllGroupMemberInfo

func (g *GroupCacheRedis) GetAllGroupMemberInfo(ctx context.Context, groupID string) ([]*relationtb.GroupMemberModel, error)

func (*GroupCacheRedis) GetAllGroupMembersInfo

func (g *GroupCacheRedis) GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationtb.GroupMemberModel, err error)

func (*GroupCacheRedis) GetGroupIndex

func (g *GroupCacheRedis) GetGroupIndex(group *relationtb.GroupModel, keys []string) (int, error)

func (*GroupCacheRedis) GetGroupInfo

func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)

func (*GroupCacheRedis) GetGroupMemberHashMap

func (g *GroupCacheRedis) GetGroupMemberHashMap(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error)

func (*GroupCacheRedis) GetGroupMemberIDs

func (g *GroupCacheRedis) GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error)

func (*GroupCacheRedis) GetGroupMemberIndex

func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationtb.GroupMemberModel, keys []string) (int, error)

func (*GroupCacheRedis) GetGroupMemberInfo

func (g *GroupCacheRedis) GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relationtb.GroupMemberModel, err error)

func (*GroupCacheRedis) GetGroupMemberNum

func (g *GroupCacheRedis) GetGroupMemberNum(ctx context.Context, groupID string) (memberNum int64, err error)

func (*GroupCacheRedis) GetGroupMembersHash

func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error)

func (*GroupCacheRedis) GetGroupMembersInfo

func (g *GroupCacheRedis) GetGroupMembersInfo(ctx context.Context, groupID string, userIDs []string) ([]*relationtb.GroupMemberModel, error)

func (*GroupCacheRedis) GetGroupMembersPage

func (g *GroupCacheRedis) GetGroupMembersPage(
	ctx context.Context,
	groupID string,
	userIDs []string,
	showNumber, pageNumber int32,
) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error)

func (*GroupCacheRedis) GetGroupOwner added in v3.4.2

func (g *GroupCacheRedis) GetGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error)

func (*GroupCacheRedis) GetGroupRoleLevelMemberIDs added in v3.4.2

func (g *GroupCacheRedis) GetGroupRoleLevelMemberIDs(ctx context.Context, groupID string, roleLevel int32) ([]string, error)

func (*GroupCacheRedis) GetGroupRoleLevelMemberInfo added in v3.4.2

func (g *GroupCacheRedis) GetGroupRoleLevelMemberInfo(ctx context.Context, groupID string, roleLevel int32) ([]*relationtb.GroupMemberModel, error)

func (*GroupCacheRedis) GetGroupRolesLevelMemberInfo added in v3.4.2

func (g *GroupCacheRedis) GetGroupRolesLevelMemberInfo(ctx context.Context, groupID string, roleLevels []int32) ([]*relationtb.GroupMemberModel, error)

func (*GroupCacheRedis) GetGroupsInfo

func (g *GroupCacheRedis) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)

func (*GroupCacheRedis) GetGroupsMemberIDs

func (g *GroupCacheRedis) GetGroupsMemberIDs(ctx context.Context, groupIDs []string) (map[string][]string, error)

func (*GroupCacheRedis) GetGroupsOwner added in v3.4.2

func (g *GroupCacheRedis) GetGroupsOwner(ctx context.Context, groupIDs []string) ([]*relationtb.GroupMemberModel, error)

func (*GroupCacheRedis) GetJoinedGroupIDs

func (g *GroupCacheRedis) GetJoinedGroupIDs(ctx context.Context, userID string) (joinedGroupIDs []string, err error)

func (*GroupCacheRedis) NewCache

func (g *GroupCacheRedis) NewCache() GroupCache

type GroupHash added in v3.4.2

type GroupHash interface {
	GetGroupHash(ctx context.Context, groupID string) (uint64, error)
}

type MinioCache added in v3.4.0

type MinioCache interface {
	GetImageObjectKeyInfo(ctx context.Context, key string, fn func(ctx context.Context) (*MinioImageInfo, error)) (*MinioImageInfo, error)
	GetThumbnailKey(ctx context.Context, key string, format string, width int, height int, minioCache func(ctx context.Context) (string, error)) (string, error)
	DelObjectImageInfoKey(keys ...string) MinioCache
	DelImageThumbnailKey(key string, format string, width int, height int) MinioCache
	// contains filtered or unexported methods
}

func NewMinioCache added in v3.4.0

func NewMinioCache(rdb redis.UniversalClient) MinioCache

type MinioImageInfo added in v3.4.0

type MinioImageInfo struct {
	IsImg  bool   `json:"isImg"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Format string `json:"format"`
	Etag   string `json:"etag"`
}

type MsgModel

type MsgModel interface {
	SeqCache

	AddTokenFlag(ctx context.Context, userID string, platformID int, token string, flag int) error
	GetTokensWithoutError(ctx context.Context, userID string, platformID int) (map[string]int, error)
	SetTokenMapByUidPid(ctx context.Context, userID string, platformID int, m map[string]int) error
	DeleteTokenByUidPid(ctx context.Context, userID string, platformID int, fields []string) error
	GetMessagesBySeq(ctx context.Context, conversationID string, seqs []int64) (seqMsg []*sdkws.MsgData, failedSeqList []int64, err error)
	SetMessageToCache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) (int, error)
	UserDeleteMsgs(ctx context.Context, conversationID string, seqs []int64, userID string) error
	DelUserDeleteMsgsList(ctx context.Context, conversationID string, seqs []int64)
	DeleteMessages(ctx context.Context, conversationID string, seqs []int64) error
	GetUserDelList(ctx context.Context, userID, conversationID string) (seqs []int64, err error)
	CleanUpOneConversationAllMsg(ctx context.Context, conversationID string) error
	DelMsgFromCache(ctx context.Context, userID string, seqList []int64) error
	SetSendMsgStatus(ctx context.Context, id string, status int32) error
	GetSendMsgStatus(ctx context.Context, id string) (int32, error)
	JudgeMessageReactionExist(ctx context.Context, clientMsgID string, sessionType int32) (bool, error)
	GetOneMessageAllReactionList(ctx context.Context, clientMsgID string, sessionType int32) (map[string]string, error)
	DeleteOneMessageKey(ctx context.Context, clientMsgID string, sessionType int32, subKey string) error
	SetMessageReactionExpire(ctx context.Context, clientMsgID string, sessionType int32, expiration time.Duration) (bool, error)
	GetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey string) (string, error)
	SetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey, value string) error
	LockMessageTypeKey(ctx context.Context, clientMsgID string, TypeKey string) error
	UnLockMessageTypeKey(ctx context.Context, clientMsgID string, TypeKey string) error
	// contains filtered or unexported methods
}

func NewMsgCacheModel

func NewMsgCacheModel(client redis.UniversalClient) MsgModel

type ObjectCache added in v3.4.0

type ObjectCache interface {
	GetName(ctx context.Context, engine string, name string) (*relationtb.ObjectModel, error)
	DelObjectName(engine string, names ...string) ObjectCache
	// contains filtered or unexported methods
}

func NewObjectCacheRedis added in v3.4.0

func NewObjectCacheRedis(rdb redis.UniversalClient, objDB relationtb.ObjectInfoModelInterface) ObjectCache

type S3Cache added in v3.4.0

type S3Cache interface {
	GetKey(ctx context.Context, engine string, key string) (*s3.ObjectInfo, error)
	DelS3Key(engine string, keys ...string) S3Cache
	// contains filtered or unexported methods
}

func NewS3Cache added in v3.4.0

func NewS3Cache(rdb redis.UniversalClient, s3 s3.Interface) S3Cache

type SeqCache

type SeqCache interface {
	SetMaxSeq(ctx context.Context, conversationID string, maxSeq int64) error
	GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error)
	GetMaxSeq(ctx context.Context, conversationID string) (int64, error)
	SetMinSeq(ctx context.Context, conversationID string, minSeq int64) error
	SetMinSeqs(ctx context.Context, seqs map[string]int64) error
	GetMinSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error)
	GetMinSeq(ctx context.Context, conversationID string) (int64, error)
	GetConversationUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error)
	GetConversationUserMinSeqs(ctx context.Context, conversationID string, userIDs []string) (map[string]int64, error)
	SetConversationUserMinSeq(ctx context.Context, conversationID string, userID string, minSeq int64) error
	// seqs map: key userID value minSeq
	SetConversationUserMinSeqs(ctx context.Context, conversationID string, seqs map[string]int64) (err error)
	// seqs map: key conversationID value minSeq
	SetUserConversationsMinSeqs(ctx context.Context, userID string, seqs map[string]int64) error
	// has read seq
	SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error
	// k: user, v: seq
	SetHasReadSeqs(ctx context.Context, conversationID string, hasReadSeqs map[string]int64) error
	// k: conversation, v :seq
	UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error
	GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error)
	GetHasReadSeq(ctx context.Context, userID string, conversationID string) (int64, error)
}

type UserCache

type UserCache interface {
	NewCache() UserCache
	GetUserInfo(ctx context.Context, userID string) (userInfo *relationtb.UserModel, err error)
	GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationtb.UserModel, error)
	DelUsersInfo(userIDs ...string) UserCache
	GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
	DelUsersGlobalRecvMsgOpt(userIDs ...string) UserCache
	GetUserStatus(ctx context.Context, userIDs []string) ([]*user.OnlineStatus, error)
	SetUserStatus(ctx context.Context, userID string, status, platformID int32) error
	// contains filtered or unexported methods
}

func NewUserCacheRedis

func NewUserCacheRedis(
	rdb redis.UniversalClient,
	userDB relationtb.UserModelInterface,
	options rockscache.Options,
) UserCache

type UserCacheRedis

type UserCacheRedis struct {
	// contains filtered or unexported fields
}

func (*UserCacheRedis) DelUsersGlobalRecvMsgOpt

func (u *UserCacheRedis) DelUsersGlobalRecvMsgOpt(userIDs ...string) UserCache

func (*UserCacheRedis) DelUsersInfo

func (u *UserCacheRedis) DelUsersInfo(userIDs ...string) UserCache

func (*UserCacheRedis) GetUserGlobalRecvMsgOpt

func (u *UserCacheRedis) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)

func (*UserCacheRedis) GetUserInfo

func (u *UserCacheRedis) GetUserInfo(ctx context.Context, userID string) (userInfo *relationtb.UserModel, err error)

func (*UserCacheRedis) GetUserStatus

func (u *UserCacheRedis) GetUserStatus(ctx context.Context, userIDs []string) ([]*user.OnlineStatus, error)

GetUserStatus get user status.

func (*UserCacheRedis) GetUsersInfo

func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationtb.UserModel, error)

func (*UserCacheRedis) NewCache

func (u *UserCacheRedis) NewCache() UserCache

func (*UserCacheRedis) SetUserStatus

func (u *UserCacheRedis) SetUserStatus(ctx context.Context, userID string, status, platformID int32) error

SetUserStatus Set the user status and save it in redis.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL