feat: msg local cache

This commit is contained in:
withchao
2024-01-08 15:39:39 +08:00
parent f27b1e43f5
commit d9921248a7
23 changed files with 778 additions and 68 deletions
+45
View File
@@ -0,0 +1,45 @@
package cachekey
import (
"strconv"
"time"
)
const (
groupExpireTime = time.Second * 60 * 60 * 12
groupInfoKey = "GROUP_INFO:"
groupMemberIDsKey = "GROUP_MEMBER_IDS:"
groupMembersHashKey = "GROUP_MEMBERS_HASH2:"
groupMemberInfoKey = "GROUP_MEMBER_INFO:"
joinedGroupsKey = "JOIN_GROUPS_KEY:"
groupMemberNumKey = "GROUP_MEMBER_NUM_CACHE:"
groupRoleLevelMemberIDsKey = "GROUP_ROLE_LEVEL_MEMBER_IDS:"
)
func GetGroupInfoKey(groupID string) string {
return groupInfoKey + groupID
}
func GetJoinedGroupsKey(userID string) string {
return joinedGroupsKey + userID
}
func GetGroupMembersHashKey(groupID string) string {
return groupMembersHashKey + groupID
}
func GetGroupMemberIDsKey(groupID string) string {
return groupMemberIDsKey + groupID
}
func GetGroupMemberInfoKey(groupID, userID string) string {
return groupMemberInfoKey + groupID + "-" + userID
}
func GetGroupMemberNumKey(groupID string) string {
return groupMemberNumKey + groupID
}
func GetGroupRoleLevelMemberIDsKey(groupID string, roleLevel int32) string {
return groupRoleLevelMemberIDsKey + groupID + "-" + strconv.Itoa(int(roleLevel))
}