mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-17 09:40:04 +08:00
localcache
This commit is contained in:
parent
da2c0d11f5
commit
ee9c9eb97c
@ -2,6 +2,7 @@ package rpccache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cachekey"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/localcache"
|
||||
@ -23,19 +24,25 @@ type FriendLocalCache struct {
|
||||
}
|
||||
|
||||
func (f *FriendLocalCache) GetFriendIDs(ctx context.Context, ownerUserID string) ([]string, error) {
|
||||
log.ZDebug(ctx, "FriendLocalCache GetFriendIDs req", "ownerUserID", ownerUserID)
|
||||
return localcache.AnyValue[[]string](f.local.Get(ctx, cachekey.GetFriendIDsKey(ownerUserID), func(ctx context.Context) (any, error) {
|
||||
log.ZDebug(ctx, "FriendLocalCache GetFriendIDs call rpc", "ownerUserID", ownerUserID)
|
||||
return f.client.GetFriendIDs(ctx, ownerUserID)
|
||||
}))
|
||||
}
|
||||
|
||||
func (f *FriendLocalCache) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) {
|
||||
log.ZDebug(ctx, "FriendLocalCache IsFriend req", "possibleFriendUserID", possibleFriendUserID, "userID", userID)
|
||||
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))))
|
||||
}
|
||||
|
||||
func (f *FriendLocalCache) IsBlocked(ctx context.Context, possibleBlackUserID, userID string) (bool, error) {
|
||||
log.ZDebug(ctx, "FriendLocalCache IsBlocked req", "possibleBlackUserID", possibleBlackUserID, "userID", userID)
|
||||
return localcache.AnyValue[bool](f.local.Get(ctx, cachekey.GetIsBlackIDsKey(possibleBlackUserID, userID), func(ctx context.Context) (any, error) {
|
||||
log.ZDebug(ctx, "FriendLocalCache IsBlocked rpc", "possibleBlackUserID", possibleBlackUserID, "userID", userID)
|
||||
return f.client.IsBlocked(ctx, possibleBlackUserID, userID)
|
||||
}, option.NewOption().WithLink(cachekey.GetBlackIDsKey(possibleBlackUserID), cachekey.GetBlackIDsKey(userID))))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user