mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 01:25:58 +08:00
feat: msg local cache
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cachekey"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/localcache"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/localcache/option"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
||||
)
|
||||
|
||||
@@ -28,11 +29,11 @@ func (f *FriendLocalCache) GetFriendIDs(ctx context.Context, ownerUserID string)
|
||||
func (f *FriendLocalCache) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) {
|
||||
return localcache.AnyValue[bool](f.local.Get(ctx, cachekey.GetIsFriendKey(possibleFriendUserID, userID), func(ctx context.Context) (any, error) {
|
||||
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) {
|
||||
return localcache.AnyValue[bool](f.local.Get(ctx, cachekey.GetIsBlackIDsKey(possibleBlackUserID, userID), func(ctx context.Context) (any, error) {
|
||||
return f.client.IsFriend(ctx, possibleBlackUserID, userID)
|
||||
}))
|
||||
return f.client.IsBlocked(ctx, possibleBlackUserID, userID)
|
||||
}, option.NewOption().WithLink(cachekey.GetBlackIDsKey(possibleBlackUserID), cachekey.GetBlackIDsKey(userID))))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user