mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-01 17:02:10 +08:00
fix: userIDs
This commit is contained in:
parent
d4fc77b556
commit
8658223c61
9
pkg/common/storage/cache/cachekey/online.go
vendored
9
pkg/common/storage/cache/cachekey/online.go
vendored
@ -1,6 +1,9 @@
|
||||
package cachekey
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
OnlineKey = "ONLINE:"
|
||||
@ -11,3 +14,7 @@ const (
|
||||
func GetOnlineKey(userID string) string {
|
||||
return OnlineKey + userID
|
||||
}
|
||||
|
||||
func GetOnlineKeyUserID(key string) string {
|
||||
return strings.TrimPrefix(key, OnlineKey)
|
||||
}
|
||||
|
||||
3
pkg/common/storage/cache/redis/online.go
vendored
3
pkg/common/storage/cache/redis/online.go
vendored
@ -60,6 +60,7 @@ func (s *userOnline) GetAllOnlineUsers(ctx context.Context, cursor uint64) (map[
|
||||
}
|
||||
|
||||
for _, key := range keys {
|
||||
userID := cachekey.GetOnlineKeyUserID(key)
|
||||
strValues, err := s.rdb.ZRange(ctx, key, 0, -1).Result()
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@ -74,7 +75,7 @@ func (s *userOnline) GetAllOnlineUsers(ctx context.Context, cursor uint64) (map[
|
||||
values = append(values, int32(intValue))
|
||||
}
|
||||
|
||||
result[key] = values
|
||||
result[userID] = values
|
||||
}
|
||||
|
||||
return result, nextCursor, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user