This commit is contained in:
29
pkg/common/storage/cache/cachekey/black.go
vendored
Normal file
29
pkg/common/storage/cache/cachekey/black.go
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey
|
||||||
|
|
||||||
|
const (
|
||||||
|
BlackIDsKey = "BLACK_IDS:"
|
||||||
|
IsBlackKey = "IS_BLACK:" // local cache
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetBlackIDsKey(ownerUserID string) string {
|
||||||
|
return BlackIDsKey + ownerUserID
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetIsBlackIDsKey(possibleBlackUserID, userID string) string {
|
||||||
|
return IsBlackKey + userID + "-" + possibleBlackUserID
|
||||||
|
}
|
||||||
10
pkg/common/storage/cache/cachekey/client_config.go
vendored
Normal file
10
pkg/common/storage/cache/cachekey/client_config.go
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package cachekey
|
||||||
|
|
||||||
|
const ClientConfig = "CLIENT_CONFIG"
|
||||||
|
|
||||||
|
func GetClientConfigKey(userID string) string {
|
||||||
|
if userID == "" {
|
||||||
|
return ClientConfig
|
||||||
|
}
|
||||||
|
return ClientConfig + ":" + userID
|
||||||
|
}
|
||||||
73
pkg/common/storage/cache/cachekey/conversation.go
vendored
Normal file
73
pkg/common/storage/cache/cachekey/conversation.go
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey
|
||||||
|
|
||||||
|
const (
|
||||||
|
ConversationKey = "CONVERSATION:"
|
||||||
|
ConversationIDsKey = "CONVERSATION_IDS:"
|
||||||
|
NotNotifyConversationIDsKey = "NOT_NOTIFY_CONVERSATION_IDS:"
|
||||||
|
PinnedConversationIDsKey = "PINNED_CONVERSATION_IDS:"
|
||||||
|
ConversationIDsHashKey = "CONVERSATION_IDS_HASH:"
|
||||||
|
ConversationHasReadSeqKey = "CONVERSATION_HAS_READ_SEQ:"
|
||||||
|
RecvMsgOptKey = "RECV_MSG_OPT:"
|
||||||
|
SuperGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
|
||||||
|
SuperGroupRecvMsgNotNotifyUserIDsHashKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS_HASH:"
|
||||||
|
ConversationNotReceiveMessageUserIDsKey = "CONVERSATION_NOT_RECEIVE_MESSAGE_USER_IDS:"
|
||||||
|
ConversationUserMaxKey = "CONVERSATION_USER_MAX:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetConversationKey(ownerUserID, conversationID string) string {
|
||||||
|
return ConversationKey + ownerUserID + ":" + conversationID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetConversationIDsKey(ownerUserID string) string {
|
||||||
|
return ConversationIDsKey + ownerUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetNotNotifyConversationIDsKey(ownerUserID string) string {
|
||||||
|
return NotNotifyConversationIDsKey + ownerUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPinnedConversationIDs(ownerUserID string) string {
|
||||||
|
return PinnedConversationIDsKey + ownerUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSuperGroupRecvNotNotifyUserIDsKey(groupID string) string {
|
||||||
|
return SuperGroupRecvMsgNotNotifyUserIDsKey + groupID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRecvMsgOptKey(ownerUserID, conversationID string) string {
|
||||||
|
return RecvMsgOptKey + ownerUserID + ":" + conversationID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSuperGroupRecvNotNotifyUserIDsHashKey(groupID string) string {
|
||||||
|
return SuperGroupRecvMsgNotNotifyUserIDsHashKey + groupID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetConversationHasReadSeqKey(ownerUserID, conversationID string) string {
|
||||||
|
return ConversationHasReadSeqKey + ownerUserID + ":" + conversationID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetConversationNotReceiveMessageUserIDsKey(conversationID string) string {
|
||||||
|
return ConversationNotReceiveMessageUserIDsKey + conversationID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserConversationIDsHashKey(ownerUserID string) string {
|
||||||
|
return ConversationIDsHashKey + ownerUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetConversationUserMaxVersionKey(userID string) string {
|
||||||
|
return ConversationUserMaxKey + userID
|
||||||
|
}
|
||||||
15
pkg/common/storage/cache/cachekey/doc.go
vendored
Normal file
15
pkg/common/storage/cache/cachekey/doc.go
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey // import "git.imall.cloud/openim/open-im-server-deploy/pkg/common/storage/cache/cachekey"
|
||||||
48
pkg/common/storage/cache/cachekey/friend.go
vendored
Normal file
48
pkg/common/storage/cache/cachekey/friend.go
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey
|
||||||
|
|
||||||
|
const (
|
||||||
|
FriendIDsKey = "FRIEND_IDS:"
|
||||||
|
TwoWayFriendsIDsKey = "COMMON_FRIENDS_IDS:"
|
||||||
|
FriendKey = "FRIEND_INFO:"
|
||||||
|
IsFriendKey = "IS_FRIEND:" // local cache key
|
||||||
|
//FriendSyncSortUserIDsKey = "FRIEND_SYNC_SORT_USER_IDS:"
|
||||||
|
FriendMaxVersionKey = "FRIEND_MAX_VERSION:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFriendIDsKey(ownerUserID string) string {
|
||||||
|
return FriendIDsKey + ownerUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetTwoWayFriendsIDsKey(ownerUserID string) string {
|
||||||
|
return TwoWayFriendsIDsKey + ownerUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetFriendKey(ownerUserID, friendUserID string) string {
|
||||||
|
return FriendKey + ownerUserID + "-" + friendUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetFriendMaxVersionKey(ownerUserID string) string {
|
||||||
|
return FriendMaxVersionKey + ownerUserID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetIsFriendKey(possibleFriendUserID, userID string) string {
|
||||||
|
return IsFriendKey + possibleFriendUserID + "-" + userID
|
||||||
|
}
|
||||||
|
|
||||||
|
//func GetFriendSyncSortUserIDsKey(ownerUserID string, count int) string {
|
||||||
|
// return FriendSyncSortUserIDsKey + strconv.Itoa(count) + ":" + ownerUserID
|
||||||
|
//}
|
||||||
70
pkg/common/storage/cache/cachekey/group.go
vendored
Normal file
70
pkg/common/storage/cache/cachekey/group.go
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
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:"
|
||||||
|
GroupAdminLevelMemberIDsKey = "GROUP_ADMIN_LEVEL_MEMBER_IDS:"
|
||||||
|
GroupMemberMaxVersionKey = "GROUP_MEMBER_MAX_VERSION:"
|
||||||
|
GroupJoinMaxVersionKey = "GROUP_JOIN_MAX_VERSION:"
|
||||||
|
)
|
||||||
|
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetGroupMemberMaxVersionKey(groupID string) string {
|
||||||
|
return GroupMemberMaxVersionKey + groupID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetJoinGroupMaxVersionKey(userID string) string {
|
||||||
|
return GroupJoinMaxVersionKey + userID
|
||||||
|
}
|
||||||
32
pkg/common/storage/cache/cachekey/msg.go
vendored
Normal file
32
pkg/common/storage/cache/cachekey/msg.go
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:"
|
||||||
|
messageCache = "MSG_CACHE:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetMsgCacheKey(conversationID string, seq int64) string {
|
||||||
|
return messageCache + conversationID + ":" + strconv.Itoa(int(seq))
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSendMsgKey(id string) string {
|
||||||
|
return sendMsgFailedFlag + id
|
||||||
|
}
|
||||||
62
pkg/common/storage/cache/cachekey/online.go
vendored
Normal file
62
pkg/common/storage/cache/cachekey/online.go
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package cachekey
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
onlineKeyBase = "ONLINE:"
|
||||||
|
onlineChannelBase = "online_change"
|
||||||
|
OnlineExpire = time.Hour / 2
|
||||||
|
// OnlineUserCountKey 在线人数缓存键
|
||||||
|
onlineUserCountKeyBase = "ONLINE_USER_COUNT"
|
||||||
|
// OnlineUserCountHistoryKey 在线人数历史缓存键
|
||||||
|
onlineUserCountHistoryKeyBase = "ONLINE_USER_COUNT_HISTORY"
|
||||||
|
// OnlineUserCountHistoryRetention 在线人数历史保留时长
|
||||||
|
OnlineUserCountHistoryRetention = 60 * 24 * time.Hour
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
OnlineKey = onlineKeyBase
|
||||||
|
OnlineChannel = onlineChannelBase
|
||||||
|
OnlineUserCountKey = onlineUserCountKeyBase
|
||||||
|
OnlineUserCountHistoryKey = onlineUserCountHistoryKeyBase
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetOnlinePrefix(prefix string, useHashTag bool, redisMode string) {
|
||||||
|
normalized := normalizeOnlinePrefix(prefix, useHashTag, redisMode)
|
||||||
|
if normalized == "" {
|
||||||
|
OnlineKey = onlineKeyBase
|
||||||
|
OnlineChannel = onlineChannelBase
|
||||||
|
OnlineUserCountKey = onlineUserCountKeyBase
|
||||||
|
OnlineUserCountHistoryKey = onlineUserCountHistoryKeyBase
|
||||||
|
return
|
||||||
|
}
|
||||||
|
OnlineKey = normalized + onlineKeyBase
|
||||||
|
OnlineChannel = normalized + onlineChannelBase
|
||||||
|
OnlineUserCountKey = normalized + onlineUserCountKeyBase
|
||||||
|
OnlineUserCountHistoryKey = normalized + onlineUserCountHistoryKeyBase
|
||||||
|
}
|
||||||
|
|
||||||
|
func normalizeOnlinePrefix(prefix string, useHashTag bool, redisMode string) string {
|
||||||
|
prefix = strings.TrimSpace(prefix)
|
||||||
|
if prefix == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
prefix = strings.TrimSuffix(prefix, ":")
|
||||||
|
if useHashTag || strings.EqualFold(redisMode, "cluster") {
|
||||||
|
if !(strings.HasPrefix(prefix, "{") && strings.HasSuffix(prefix, "}")) {
|
||||||
|
prefix = "{" + prefix + "}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return prefix + ":"
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOnlineKey(userID string) string {
|
||||||
|
return OnlineKey + userID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOnlineKeyUserID(key string) string {
|
||||||
|
return strings.TrimPrefix(key, OnlineKey)
|
||||||
|
}
|
||||||
40
pkg/common/storage/cache/cachekey/s3.go
vendored
Normal file
40
pkg/common/storage/cache/cachekey/s3.go
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey
|
||||||
|
|
||||||
|
import "strconv"
|
||||||
|
|
||||||
|
const (
|
||||||
|
object = "OBJECT:"
|
||||||
|
s3 = "S3:"
|
||||||
|
minioImageInfo = "MINIO:IMAGE:"
|
||||||
|
minioThumbnail = "MINIO:THUMBNAIL:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetObjectKey(engine string, name string) string {
|
||||||
|
return object + engine + ":" + name
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetS3Key(engine string, name string) string {
|
||||||
|
return s3 + engine + ":" + name
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetObjectImageInfoKey(key string) string {
|
||||||
|
return minioImageInfo + key
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMinioImageThumbnailKey(key string, format string, width int, height int) string {
|
||||||
|
return minioThumbnail + format + ":w" + strconv.Itoa(width) + ":h" + strconv.Itoa(height) + ":" + key
|
||||||
|
}
|
||||||
30
pkg/common/storage/cache/cachekey/seq.go
vendored
Normal file
30
pkg/common/storage/cache/cachekey/seq.go
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package cachekey
|
||||||
|
|
||||||
|
const (
|
||||||
|
MallocSeq = "MALLOC_SEQ:"
|
||||||
|
MallocMinSeqLock = "MALLOC_MIN_SEQ:"
|
||||||
|
|
||||||
|
SeqUserMaxSeq = "SEQ_USER_MAX:"
|
||||||
|
SeqUserMinSeq = "SEQ_USER_MIN:"
|
||||||
|
SeqUserReadSeq = "SEQ_USER_READ:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetMallocSeqKey(conversationID string) string {
|
||||||
|
return MallocSeq + conversationID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMallocMinSeqKey(conversationID string) string {
|
||||||
|
return MallocMinSeqLock + conversationID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSeqUserMaxSeqKey(conversationID string, userID string) string {
|
||||||
|
return SeqUserMaxSeq + conversationID + ":" + userID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSeqUserMinSeqKey(conversationID string, userID string) string {
|
||||||
|
return SeqUserMinSeq + conversationID + ":" + userID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSeqUserReadSeqKey(conversationID string, userID string) string {
|
||||||
|
return SeqUserReadSeq + conversationID + ":" + userID
|
||||||
|
}
|
||||||
41
pkg/common/storage/cache/cachekey/third.go
vendored
Normal file
41
pkg/common/storage/cache/cachekey/third.go
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
getuiToken = "GETUI_TOKEN"
|
||||||
|
getuiTaskID = "GETUI_TASK_ID"
|
||||||
|
fmcToken = "FCM_TOKEN:"
|
||||||
|
userBadgeUnreadCountSum = "USER_BADGE_UNREAD_COUNT_SUM:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFcmAccountTokenKey(account string, platformID int) string {
|
||||||
|
return fmcToken + account + ":" + strconv.Itoa(platformID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserBadgeUnreadCountSumKey(userID string) string {
|
||||||
|
return userBadgeUnreadCountSum + userID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetGetuiTokenKey() string {
|
||||||
|
return getuiToken
|
||||||
|
}
|
||||||
|
func GetGetuiTaskIDKey() string {
|
||||||
|
return getuiTaskID
|
||||||
|
}
|
||||||
33
pkg/common/storage/cache/cachekey/token.go
vendored
Normal file
33
pkg/common/storage/cache/cachekey/token.go
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package cachekey
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"git.imall.cloud/openim/protocol/constant"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
UidPidToken = "UID_PID_TOKEN_STATUS:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetTokenKey(userID string, platformID int) string {
|
||||||
|
return UidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetTemporaryTokenKey(userID string, platformID int, token string) string {
|
||||||
|
return UidPidToken + ":TEMPORARY:" + userID + ":" + constant.PlatformIDToName(platformID) + ":" + token
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllPlatformTokenKey(userID string) []string {
|
||||||
|
res := make([]string, len(constant.PlatformID2Name))
|
||||||
|
for k := range constant.PlatformID2Name {
|
||||||
|
res[k-1] = GetTokenKey(userID, k)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPlatformIDByTokenKey(key string) int {
|
||||||
|
splitKey := strings.Split(key, ":")
|
||||||
|
platform := splitKey[len(splitKey)-1]
|
||||||
|
return constant.PlatformNameToID(platform)
|
||||||
|
}
|
||||||
28
pkg/common/storage/cache/cachekey/user.go
vendored
Normal file
28
pkg/common/storage/cache/cachekey/user.go
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// Copyright © 2024 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cachekey
|
||||||
|
|
||||||
|
const (
|
||||||
|
UserInfoKey = "USER_INFO:"
|
||||||
|
UserGlobalRecvMsgOptKey = "USER_GLOBAL_RECV_MSG_OPT_KEY:"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetUserInfoKey(userID string) string {
|
||||||
|
return UserInfoKey + userID
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserGlobalRecvMsgOptKey(userID string) string {
|
||||||
|
return UserGlobalRecvMsgOptKey + userID
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user