redis

package
v3.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 32 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCacheBySlot

func DeleteCacheBySlot(ctx context.Context, rcClient *rockscache.Client, keys []string) error

func GetRocksCacheOptions

func GetRocksCacheOptions() *rockscache.Options

GetRocksCacheOptions returns the default configuration options for RocksCache.

func LuaDeleteBatch

func LuaDeleteBatch(ctx context.Context, rdb redis.Scripter, keys []string) error

func LuaGetBatch

func LuaGetBatch(ctx context.Context, rdb redis.Scripter, keys []string) ([]any, error)

func LuaSetBatchWithCommonExpire

func LuaSetBatchWithCommonExpire(ctx context.Context, rdb redis.Scripter, keys []string, values []string, expire int) error

func LuaSetBatchWithIndividualExpire

func LuaSetBatchWithIndividualExpire(ctx context.Context, rdb redis.Scripter, keys []string, values []string, expires []int) error

func NewBlackCacheRedis

func NewBlackCacheRedis(rdb redis.UniversalClient, localCache *config.LocalCache, blackDB database.Black, options *rockscache.Options) cache.BlackCache

func NewConversationRedis

func NewConversationRedis(rdb redis.UniversalClient, localCache *config.LocalCache, opts *rockscache.Options, db database.Conversation) cache.ConversationCache

func NewFriendCacheRedis

func NewFriendCacheRedis(rdb redis.UniversalClient, localCache *config.LocalCache, friendDB database.Friend,
	options *rockscache.Options) cache.FriendCache

NewFriendCacheRedis creates a new instance of FriendCacheRedis.

func NewGroupCacheRedis

func NewGroupCacheRedis(
	rdb redis.UniversalClient,
	localCache *config.LocalCache,
	groupDB database.Group,
	groupMemberDB database.GroupMember,
	groupRequestDB database.GroupRequest,
	hashCode cache.GroupHash,
	opts *rockscache.Options,
) cache.GroupCache

func NewMinioCache

func NewMinioCache(rdb redis.UniversalClient) minio.Cache

func NewMsgCache

func NewMsgCache(client redis.UniversalClient) cache.MsgCache

func NewObjectCacheRedis

func NewObjectCacheRedis(rdb redis.UniversalClient, objDB database.ObjectInfo) cache.ObjectCache

func NewS3Cache

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

func NewSeqConversationCacheRedis

func NewSeqConversationCacheRedis(rdb redis.UniversalClient, mgo database.SeqConversation) cache.SeqConversationCache

func NewSeqUserCacheRedis

func NewSeqUserCacheRedis(rdb redis.UniversalClient, mgo database.SeqUser) cache.SeqUser

func NewThirdCache

func NewThirdCache(rdb redis.UniversalClient) cache.ThirdCache

func NewTokenCacheModel

func NewTokenCacheModel(rdb redis.UniversalClient, accessExpire int64) cache.TokenModel

func NewUserCacheRedis

func NewUserCacheRedis(rdb redis.UniversalClient, localCache *config.LocalCache, userDB database.User, options *rockscache.Options) cache.UserCache

func NewUserOnline

func NewUserOnline(rdb redis.UniversalClient) cache.OnlineCache

func ProcessKeysBySlot

func ProcessKeysBySlot(
	ctx context.Context,
	redisClient redis.UniversalClient,
	keys []string,
	processFunc func(ctx context.Context, slot int64, keys []string) error,
	opts ...Option,
) error

ProcessKeysBySlot groups keys by their Redis cluster hash slots and processes them using the provided function.

Types

type BatchCacheCallback

type BatchCacheCallback[K comparable] interface {
	BatchCache(id K)
}

type BatchDeleterRedis

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

BatchDeleterRedis is a concrete implementation of the BatchDeleter interface based on Redis and RocksCache.

func NewBatchDeleterRedis

func NewBatchDeleterRedis(redisClient redis.UniversalClient, options *rockscache.Options, redisPubTopics []string) *BatchDeleterRedis

NewBatchDeleterRedis creates a new BatchDeleterRedis instance.

func (*BatchDeleterRedis) AddKeys

func (c *BatchDeleterRedis) AddKeys(keys ...string)

AddKeys adds keys to be deleted.

func (*BatchDeleterRedis) ChainExecDel

func (c *BatchDeleterRedis) ChainExecDel(ctx context.Context) error

ChainExecDel is used for chain calls for batch deletion. It must call Clone to prevent memory pollution.

func (*BatchDeleterRedis) Clone

Clone creates a copy of BatchDeleterRedis for chain calls to prevent memory pollution.

func (*BatchDeleterRedis) ExecDelWithKeys

func (c *BatchDeleterRedis) ExecDelWithKeys(ctx context.Context, keys []string) error

ExecDelWithKeys directly takes keys for batch deletion and publishes deletion information.

type BlackCacheRedis

type BlackCacheRedis struct {
	cache.BatchDeleter
	// contains filtered or unexported fields
}

func (*BlackCacheRedis) CloneBlackCache

func (b *BlackCacheRedis) CloneBlackCache() cache.BlackCache

func (*BlackCacheRedis) DelBlackIDs

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

func (*BlackCacheRedis) GetBlackIDs

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

type Config

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

type ConversationRedisCache

type ConversationRedisCache struct {
	cache.BatchDeleter
	// contains filtered or unexported fields
}

func (*ConversationRedisCache) CloneConversationCache

func (c *ConversationRedisCache) CloneConversationCache() cache.ConversationCache

func (*ConversationRedisCache) DelConversationIDs

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

func (*ConversationRedisCache) DelConversationNotNotifyMessageUserIDs added in v3.8.1

func (c *ConversationRedisCache) DelConversationNotNotifyMessageUserIDs(userIDs ...string) cache.ConversationCache

func (*ConversationRedisCache) DelConversationNotReceiveMessageUserIDs

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

func (*ConversationRedisCache) DelConversationPinnedMessageUserIDs added in v3.8.1

func (c *ConversationRedisCache) DelConversationPinnedMessageUserIDs(userIDs ...string) cache.ConversationCache

func (*ConversationRedisCache) DelConversationVersionUserIDs

func (c *ConversationRedisCache) DelConversationVersionUserIDs(userIDs ...string) cache.ConversationCache

func (*ConversationRedisCache) DelConversations

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

func (*ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDs

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

func (*ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash

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

func (*ConversationRedisCache) DelUserAllHasReadSeqs

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

func (*ConversationRedisCache) DelUserConversationIDsHash

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

func (*ConversationRedisCache) DelUserRecvMsgOpt

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

func (*ConversationRedisCache) DelUsersConversation

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

func (*ConversationRedisCache) FindMaxConversationUserVersion

func (c *ConversationRedisCache) FindMaxConversationUserVersion(ctx context.Context, userID string) (*model.VersionLog, error)

func (*ConversationRedisCache) GetConversation

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

func (*ConversationRedisCache) GetConversationNotReceiveMessageUserIDs

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) ([]*model.Conversation, error)

func (*ConversationRedisCache) GetPinnedConversationIDs added in v3.8.1

func (c *ConversationRedisCache) GetPinnedConversationIDs(ctx context.Context, userID string) ([]string, error)

func (*ConversationRedisCache) GetUserAllConversations

func (c *ConversationRedisCache) GetUserAllConversations(ctx context.Context, ownerUserID string) ([]*model.Conversation, 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) GetUserNotNotifyConversationIDs added in v3.8.1

func (c *ConversationRedisCache) GetUserNotNotifyConversationIDs(ctx context.Context, userID string) ([]string, error)

func (*ConversationRedisCache) GetUserRecvMsgOpt

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

type FriendCacheRedis

type FriendCacheRedis struct {
	cache.BatchDeleter
	// contains filtered or unexported fields
}

FriendCacheRedis is an implementation of the FriendCache interface using Redis.

func (*FriendCacheRedis) CloneFriendCache

func (f *FriendCacheRedis) CloneFriendCache() cache.FriendCache

func (*FriendCacheRedis) DelFriend

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

DelFriend deletes friend info from the cache.

func (*FriendCacheRedis) DelFriendIDs

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

DelFriendIDs deletes friend IDs from the cache.

func (*FriendCacheRedis) DelFriends

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

DelFriends deletes multiple friend infos from the cache.

func (*FriendCacheRedis) DelMaxFriendVersion

func (f *FriendCacheRedis) DelMaxFriendVersion(ownerUserIDs ...string) cache.FriendCache

func (*FriendCacheRedis) DelOwner

func (f *FriendCacheRedis) DelOwner(friendUserID string, ownerUserIDs []string) cache.FriendCache

func (*FriendCacheRedis) DelTwoWayFriendIDs

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

DelTwoWayFriendIDs deletes two-way friend IDs from the cache.

func (*FriendCacheRedis) FindMaxFriendVersion

func (f *FriendCacheRedis) FindMaxFriendVersion(ctx context.Context, ownerUserID string) (*model.VersionLog, error)

func (*FriendCacheRedis) GetFriend

func (f *FriendCacheRedis) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *model.Friend, 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.

type GroupCacheRedis

type GroupCacheRedis struct {
	cache.BatchDeleter
	// contains filtered or unexported fields
}

func (*GroupCacheRedis) BatchFindMaxGroupMemberVersion

func (g *GroupCacheRedis) BatchFindMaxGroupMemberVersion(ctx context.Context, groupIDs []string) ([]*model.VersionLog, error)

func (*GroupCacheRedis) CloneGroupCache

func (g *GroupCacheRedis) CloneGroupCache() cache.GroupCache

func (*GroupCacheRedis) DelGroupAllRoleLevel

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

func (*GroupCacheRedis) DelGroupMemberIDs

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

func (*GroupCacheRedis) DelGroupMembersHash

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

func (*GroupCacheRedis) DelGroupMembersInfo

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

func (*GroupCacheRedis) DelGroupRoleLevel

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

func (*GroupCacheRedis) DelGroupsInfo

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

func (*GroupCacheRedis) DelGroupsMemberNum

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

func (*GroupCacheRedis) DelGroupsOwner

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

func (*GroupCacheRedis) DelJoinedGroupID

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

func (*GroupCacheRedis) DelMaxGroupMemberVersion

func (g *GroupCacheRedis) DelMaxGroupMemberVersion(groupIDs ...string) cache.GroupCache

func (*GroupCacheRedis) DelMaxJoinGroupVersion

func (g *GroupCacheRedis) DelMaxJoinGroupVersion(userIDs ...string) cache.GroupCache

func (*GroupCacheRedis) FindGroupMemberUser

func (g *GroupCacheRedis) FindGroupMemberUser(ctx context.Context, groupIDs []string, userID string) ([]*model.GroupMember, error)

func (*GroupCacheRedis) FindMaxGroupMemberVersion

func (g *GroupCacheRedis) FindMaxGroupMemberVersion(ctx context.Context, groupID string) (*model.VersionLog, error)

func (*GroupCacheRedis) FindMaxJoinGroupVersion

func (g *GroupCacheRedis) FindMaxJoinGroupVersion(ctx context.Context, userID string) (*model.VersionLog, error)

func (*GroupCacheRedis) GetAllGroupMembersInfo

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

func (*GroupCacheRedis) GetGroupInfo

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

func (*GroupCacheRedis) GetGroupMemberHashMap

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

func (*GroupCacheRedis) GetGroupMemberIDs

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

func (*GroupCacheRedis) GetGroupMemberInfo

func (g *GroupCacheRedis) GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *model.GroupMember, 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) ([]*model.GroupMember, error)

func (*GroupCacheRedis) GetGroupOwner

func (g *GroupCacheRedis) GetGroupOwner(ctx context.Context, groupID string) (*model.GroupMember, error)

func (*GroupCacheRedis) GetGroupRoleLevelMemberIDs

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

func (*GroupCacheRedis) GetGroupRoleLevelMemberInfo

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

func (*GroupCacheRedis) GetGroupRolesLevelMemberInfo

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

func (*GroupCacheRedis) GetGroupsInfo

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

func (*GroupCacheRedis) GetGroupsOwner

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

func (*GroupCacheRedis) GetJoinedGroupIDs

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

type Option

type Option func(c *Config)

Option is a function type for configuring Config

func WithBatchSize

func WithBatchSize(size int) Option

WithBatchSize sets the number of keys to process per batch

func WithConcurrentLimit

func WithConcurrentLimit(limit int) Option

WithConcurrentLimit sets the concurrency limit

func WithContinueOnError

func WithContinueOnError(continueOnError bool) Option

WithContinueOnError sets whether to continue processing on error

type RedisShardManager

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

RedisShardManager is a class for sharding and processing keys

func NewRedisShardManager

func NewRedisShardManager(redisClient redis.UniversalClient, opts ...Option) *RedisShardManager

NewRedisShardManager creates a new RedisShardManager instance

func (*RedisShardManager) ProcessKeysBySlot

func (rsm *RedisShardManager) ProcessKeysBySlot(
	ctx context.Context,
	keys []string,
	processFunc func(ctx context.Context, slot int64, keys []string) error,
) error

ProcessKeysBySlot groups keys by their Redis cluster hash slots and processes them using the provided function.

type UserCacheRedis

type UserCacheRedis struct {
	cache.BatchDeleter
	// contains filtered or unexported fields
}

func (*UserCacheRedis) CloneUserCache

func (u *UserCacheRedis) CloneUserCache() cache.UserCache

func (*UserCacheRedis) DelUsersGlobalRecvMsgOpt

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

func (*UserCacheRedis) DelUsersInfo

func (u *UserCacheRedis) DelUsersInfo(userIDs ...string) cache.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 *model.User, err error)

func (*UserCacheRedis) GetUsersInfo

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

Jump to

Keyboard shortcuts

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