mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-28 22:58:10 +08:00
feat: online status supports redis cluster
This commit is contained in:
parent
3b6463de35
commit
d2e16752cd
2
pkg/common/storage/cache/redis/online.go
vendored
2
pkg/common/storage/cache/redis/online.go
vendored
@ -82,7 +82,7 @@ func (s *userOnline) SetUserOnline(ctx context.Context, userID string, online, o
|
|||||||
for _, platformID := range online {
|
for _, platformID := range online {
|
||||||
argv = append(argv, platformID)
|
argv = append(argv, platformID)
|
||||||
}
|
}
|
||||||
keys := []string{s.getUserOnlineKey(userID), userID}
|
keys := []string{s.getUserOnlineKey(userID)}
|
||||||
platformIDs, err := s.rdb.Eval(ctx, script, keys, argv).StringSlice()
|
platformIDs, err := s.rdb.Eval(ctx, script, keys, argv).StringSlice()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "redis SetUserOnline", err, "userID", userID, "online", online, "offline", offline)
|
log.ZError(ctx, "redis SetUserOnline", err, "userID", userID, "online", online, "offline", offline)
|
||||||
|
|||||||
26
pkg/common/storage/cache/redis/online_test.go
vendored
26
pkg/common/storage/cache/redis/online_test.go
vendored
@ -18,18 +18,18 @@ maxRetry: 10
|
|||||||
*/
|
*/
|
||||||
func TestName111111(t *testing.T) {
|
func TestName111111(t *testing.T) {
|
||||||
conf := config.Redis{
|
conf := config.Redis{
|
||||||
//Address: []string{
|
Address: []string{
|
||||||
// "172.16.8.48:7001",
|
"172.16.8.124:7001",
|
||||||
// "172.16.8.48:7002",
|
"172.16.8.124:7002",
|
||||||
// "172.16.8.48:7003",
|
"172.16.8.124:7003",
|
||||||
// "172.16.8.48:7004",
|
"172.16.8.124:7004",
|
||||||
// "172.16.8.48:7005",
|
"172.16.8.124:7005",
|
||||||
// "172.16.8.48:7006",
|
"172.16.8.124:7006",
|
||||||
//},
|
},
|
||||||
//ClusterMode: true,
|
ClusterMode: true,
|
||||||
//Password: "passwd123",
|
Password: "passwd123",
|
||||||
Address: []string{"localhost:16379"},
|
//Address: []string{"localhost:16379"},
|
||||||
Password: "openIM123",
|
//Password: "openIM123",
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1000)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1000)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -39,7 +39,7 @@ func TestName111111(t *testing.T) {
|
|||||||
}
|
}
|
||||||
online := NewUserOnline(rdb)
|
online := NewUserOnline(rdb)
|
||||||
|
|
||||||
userID := "123456"
|
userID := "a123456"
|
||||||
t.Log(online.GetOnline(ctx, userID))
|
t.Log(online.GetOnline(ctx, userID))
|
||||||
t.Log(online.SetUserOnline(ctx, userID, []int32{1, 2, 3, 4}, nil))
|
t.Log(online.SetUserOnline(ctx, userID, []int32{1, 2, 3, 4}, nil))
|
||||||
t.Log(online.GetOnline(ctx, userID))
|
t.Log(online.GetOnline(ctx, userID))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user