mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-02 17:32:11 +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
|
package cachekey
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
OnlineKey = "ONLINE:"
|
OnlineKey = "ONLINE:"
|
||||||
@ -11,3 +14,7 @@ const (
|
|||||||
func GetOnlineKey(userID string) string {
|
func GetOnlineKey(userID string) string {
|
||||||
return OnlineKey + userID
|
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 {
|
for _, key := range keys {
|
||||||
|
userID := cachekey.GetOnlineKeyUserID(key)
|
||||||
strValues, err := s.rdb.ZRange(ctx, key, 0, -1).Result()
|
strValues, err := s.rdb.ZRange(ctx, key, 0, -1).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -74,7 +75,7 @@ func (s *userOnline) GetAllOnlineUsers(ctx context.Context, cursor uint64) (map[
|
|||||||
values = append(values, int32(intValue))
|
values = append(values, int32(intValue))
|
||||||
}
|
}
|
||||||
|
|
||||||
result[key] = values
|
result[userID] = values
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nextCursor, nil
|
return result, nextCursor, nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user