diff --git a/deployments/templates/openim.yaml b/deployments/templates/openim.yaml index 4c84373a5..69f578f81 100644 --- a/deployments/templates/openim.yaml +++ b/deployments/templates/openim.yaml @@ -527,3 +527,9 @@ prometheus: rtcPrometheusPort: [ ${RTC_PROM_PORT} ] thirdPrometheusPort: [ ${THIRD_PROM_PORT} ] messageTransferPrometheusPort: [ ${MSG_TRANSFER_PROM_PORT} ] # List of ports + +localCache: + friend: + topic: friend + slotNum: 500 + slotSize: 20000 \ No newline at end of file diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 02e123bac..9c76c6009 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -16,8 +16,6 @@ package friend import ( "context" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" - "github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/protocol/sdkws" @@ -55,11 +53,6 @@ type friendServer struct { } func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error { - - config.Config.LocalCache.Friend.Topic = "friend" - config.Config.LocalCache.Friend.SlotNum = 500 - config.Config.LocalCache.Friend.SlotSize = 20000 - // Initialize MongoDB mongo, err := unrelation.NewMongo() if err != nil { diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 1c919372f..f5b1dd823 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -16,7 +16,6 @@ package msg import ( "context" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/rpccache" "google.golang.org/grpc" @@ -66,11 +65,6 @@ func (m *msgServer) execInterceptorHandler(ctx context.Context, req *msg.SendMsg } func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error { - - config.Config.LocalCache.Friend.Topic = "friend" - config.Config.LocalCache.Friend.SlotNum = 500 - config.Config.LocalCache.Friend.SlotSize = 20000 - rdb, err := cache.NewRedis() if err != nil { return err diff --git a/pkg/common/cachekey/black.go b/pkg/common/cachekey/black.go index 841e10c6a..136972cb7 100644 --- a/pkg/common/cachekey/black.go +++ b/pkg/common/cachekey/black.go @@ -11,5 +11,5 @@ func GetBlackIDsKey(ownerUserID string) string { } func GetIsBlackIDsKey(possibleBlackUserID, userID string) string { - return isBlackKey + possibleBlackUserID + "-" + userID + return isBlackKey + userID + "-" + possibleBlackUserID } diff --git a/pkg/rpccache/friend.go b/pkg/rpccache/friend.go index f519f6f14..14adf1e0a 100644 --- a/pkg/rpccache/friend.go +++ b/pkg/rpccache/friend.go @@ -50,9 +50,10 @@ func (f *FriendLocalCache) IsFriend(ctx context.Context, possibleFriendUserID, u return localcache.AnyValue[bool](f.local.Get(ctx, cachekey.GetIsFriendKey(possibleFriendUserID, userID), func(ctx context.Context) (any, error) { log.ZDebug(ctx, "FriendLocalCache IsFriend rpc", "possibleFriendUserID", possibleFriendUserID, "userID", userID) return f.client.IsFriend(ctx, possibleFriendUserID, userID) - }, option.NewOption().WithLink(cachekey.GetFriendIDsKey(possibleFriendUserID), cachekey.GetFriendIDsKey(userID)))) + }, option.NewOption().WithLink(cachekey.GetFriendIDsKey(possibleFriendUserID)))) } +// IsBlack possibleBlackUserID selfUserID func (f *FriendLocalCache) IsBlack(ctx context.Context, possibleBlackUserID, userID string) (val bool, err error) { log.ZDebug(ctx, "FriendLocalCache IsBlack req", "possibleBlackUserID", possibleBlackUserID, "userID", userID) defer func() { @@ -65,5 +66,5 @@ func (f *FriendLocalCache) IsBlack(ctx context.Context, possibleBlackUserID, use return localcache.AnyValue[bool](f.local.Get(ctx, cachekey.GetIsBlackIDsKey(possibleBlackUserID, userID), func(ctx context.Context) (any, error) { log.ZDebug(ctx, "FriendLocalCache IsBlack rpc", "possibleBlackUserID", possibleBlackUserID, "userID", userID) return f.client.IsBlack(ctx, possibleBlackUserID, userID) - }, option.NewOption().WithLink(cachekey.GetBlackIDsKey(possibleBlackUserID), cachekey.GetBlackIDsKey(userID)))) + }, option.NewOption().WithLink(cachekey.GetBlackIDsKey(userID)))) }