mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 18:45:58 +08:00
feat: cache batch
This commit is contained in:
@@ -88,6 +88,22 @@ func (x *LayLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
||||
return v.value, v.err
|
||||
}
|
||||
|
||||
func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func() ([]V, error)) ([]V, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (x *LayLRU[K, V]) SetHasBatch(data map[K]V) bool {
|
||||
x.lock.Lock()
|
||||
defer x.lock.Unlock()
|
||||
for key, value := range data {
|
||||
if x.core.Contains(key) {
|
||||
x.core.Add(key, &layLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//func (x *LayLRU[K, V]) Set(key K, value V) {
|
||||
// x.lock.Lock()
|
||||
// x.core.Add(key, &layLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
||||
|
||||
@@ -77,6 +77,15 @@ func (o *OnlineCache) GetUserOnline(ctx context.Context, userID string) (bool, e
|
||||
return len(platformIDs) > 0, nil
|
||||
}
|
||||
|
||||
func (o *OnlineCache) GetUsersOnline(ctx context.Context, usersID []string) ([]string, []string, error) {
|
||||
var (
|
||||
onlineUserIDS []string
|
||||
offlineUserIDs []string
|
||||
)
|
||||
|
||||
return onlineUserIDS, offlineUserIDs, nil
|
||||
}
|
||||
|
||||
//func (o *OnlineCache) GetUsersOnline(ctx context.Context, userIDs []string) ([]string, error) {
|
||||
// onlineUserIDs := make([]string, 0, len(userIDs))
|
||||
// for _, userID := range userIDs {
|
||||
|
||||
Reference in New Issue
Block a user