mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-18 00:46:41 +08:00
localcache
This commit is contained in:
parent
7a67beb7a1
commit
da2c0d11f5
2
pkg/common/db/cache/black.go
vendored
2
pkg/common/db/cache/black.go
vendored
@ -73,7 +73,7 @@ func (b *BlackCacheRedis) NewCache() BlackCache {
|
|||||||
expireTime: b.expireTime,
|
expireTime: b.expireTime,
|
||||||
rcClient: b.rcClient,
|
rcClient: b.rcClient,
|
||||||
blackDB: b.blackDB,
|
blackDB: b.blackDB,
|
||||||
metaCache: NewMetaCacheRedis(b.rcClient, b.metaCache.GetPreDelKeys()...),
|
metaCache: b.metaCache.Copy(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pkg/common/db/cache/friend.go
vendored
2
pkg/common/db/cache/friend.go
vendored
@ -80,7 +80,7 @@ func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationtb.FriendMo
|
|||||||
func (f *FriendCacheRedis) NewCache() FriendCache {
|
func (f *FriendCacheRedis) NewCache() FriendCache {
|
||||||
return &FriendCacheRedis{
|
return &FriendCacheRedis{
|
||||||
rcClient: f.rcClient,
|
rcClient: f.rcClient,
|
||||||
metaCache: NewMetaCacheRedis(f.rcClient, f.metaCache.GetPreDelKeys()...),
|
metaCache: f.metaCache.Copy(),
|
||||||
friendDB: f.friendDB,
|
friendDB: f.friendDB,
|
||||||
expireTime: f.expireTime,
|
expireTime: f.expireTime,
|
||||||
}
|
}
|
||||||
|
17
pkg/common/db/cache/meta_cache.go
vendored
17
pkg/common/db/cache/meta_cache.go
vendored
@ -47,6 +47,7 @@ type metaCache interface {
|
|||||||
GetPreDelKeys() []string
|
GetPreDelKeys() []string
|
||||||
SetTopic(topic string)
|
SetTopic(topic string)
|
||||||
SetRawRedisClient(cli redis.UniversalClient)
|
SetRawRedisClient(cli redis.UniversalClient)
|
||||||
|
Copy() metaCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMetaCacheRedis(rcClient *rockscache.Client, keys ...string) metaCache {
|
func NewMetaCacheRedis(rcClient *rockscache.Client, keys ...string) metaCache {
|
||||||
@ -62,6 +63,22 @@ type metaCacheRedis struct {
|
|||||||
redisClient redis.UniversalClient
|
redisClient redis.UniversalClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *metaCacheRedis) Copy() metaCache {
|
||||||
|
var keys []string
|
||||||
|
if len(m.keys) > 0 {
|
||||||
|
keys = make([]string, 0, len(m.keys)*2)
|
||||||
|
keys = append(keys, m.keys...)
|
||||||
|
}
|
||||||
|
return &metaCacheRedis{
|
||||||
|
topic: m.topic,
|
||||||
|
rcClient: m.rcClient,
|
||||||
|
keys: keys,
|
||||||
|
maxRetryTimes: m.maxRetryTimes,
|
||||||
|
retryInterval: m.retryInterval,
|
||||||
|
redisClient: redisClient,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *metaCacheRedis) SetTopic(topic string) {
|
func (m *metaCacheRedis) SetTopic(topic string) {
|
||||||
m.topic = topic
|
m.topic = topic
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ func (u *UserMgo) Exist(ctx context.Context, userID string) (exist bool, err err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserMgo) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error) {
|
func (u *UserMgo) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error) {
|
||||||
return mgoutil.FindOne[int](ctx, u.coll, bson.M{"user_id": userID}, options.FindOne().SetProjection(bson.M{"global_recv_msg_opt": 1}))
|
return mgoutil.FindOne[int](ctx, u.coll, bson.M{"user_id": userID}, options.FindOne().SetProjection(bson.M{"_id": 0, "global_recv_msg_opt": 1}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserMgo) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
func (u *UserMgo) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user