mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-19 04:37:01 +08:00
fix: resolve deadlock in cache eviction and improve GetBatch implementation
This commit is contained in:
parent
f485f92b00
commit
59c6136ba8
@ -3,15 +3,16 @@ package rpccache
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
|
||||||
"github.com/openimsdk/protocol/user"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
"github.com/openimsdk/protocol/constant"
|
||||||
|
"github.com/openimsdk/protocol/user"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
||||||
@ -46,7 +47,7 @@ func NewOnlineCache(client *rpcli.UserClient, group *GroupLocalCache, rdb redis.
|
|||||||
case false:
|
case false:
|
||||||
log.ZDebug(ctx, "fullUserCache is false")
|
log.ZDebug(ctx, "fullUserCache is false")
|
||||||
x.lruCache = lru.NewSlotLRU(1024, localcache.LRUStringHash, func() lru.LRU[string, []int32] {
|
x.lruCache = lru.NewSlotLRU(1024, localcache.LRUStringHash, func() lru.LRU[string, []int32] {
|
||||||
return lru.NewLayLRU[string, []int32](2048, cachekey.OnlineExpire/2, time.Second*3, localcache.EmptyTarget{}, func(key string, value []int32) {})
|
return lru.NewLazyLRU[string, []int32](2048, cachekey.OnlineExpire/2, time.Second*3, localcache.EmptyTarget{}, func(key string, value []int32) {})
|
||||||
})
|
})
|
||||||
x.CurrentPhase.Store(DoSubscribeOver)
|
x.CurrentPhase.Store(DoSubscribeOver)
|
||||||
x.Cond.Broadcast()
|
x.Cond.Broadcast()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user