fix: not support redis cluster. CROSSSLOT Keys in request don't hash to the same slot (#1258)

* feat: v2 to v3 data conversion

* feat: v2 to v3 data conversion

* fix: CallbackBeforeCreateGroup

* fix: NotificationUserInfoUpdate

* fix: NotificationUserInfoUpdate

* chore: update pkg github.com/OpenIMSDK/protocol v0.0.26

* chore: code format

* update pkg

* feat: QuitGroup support administrator operations

* feat: QuitGroup support administrator operations

* fix: checkMongo uri

* fix: k8s minio prefix

* fix: k8s minio prefix

* fix: k8s minio prefix

* fix: k8s minio prefix test

* fix: k8s minio prefix test

* fix: GetUsersInfo cache

* fix: redis cache

* fix: redis remove pipeline

* fix: redis remove pipeline
This commit is contained in:
withchao
2023-10-23 08:24:22 -05:00
committed by GitHub
parent b1415473ff
commit 6ffcfbe68e
8 changed files with 543 additions and 694 deletions
+26 -23
View File
@@ -112,29 +112,32 @@ func (u *UserCacheRedis) GetUserInfo(ctx context.Context, userID string) (userIn
}
func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationtb.UserModel, error) {
keys := make([]string, 0, len(userIDs))
for _, userID := range userIDs {
keys = append(keys, u.getUserInfoKey(userID))
}
return batchGetCache(
ctx,
u.rcClient,
keys,
u.expireTime,
func(user *relationtb.UserModel, keys []string) (int, error) {
for i, key := range keys {
if key == u.getUserInfoKey(user.UserID) {
return i, nil
}
}
return 0, errIndex
},
func(ctx context.Context) ([]*relationtb.UserModel, error) {
return u.userDB.Find(ctx, userIDs)
},
)
//var keys []string
//for _, userID := range userIDs {
// keys = append(keys, u.getUserInfoKey(userID))
//}
//return batchGetCache(
// ctx,
// u.rcClient,
// keys,
// u.expireTime,
// func(user *relationtb.UserModel, keys []string) (int, error) {
// for i, key := range keys {
// if key == u.getUserInfoKey(user.UserID) {
// return i, nil
// }
// }
// return 0, errIndex
// },
// func(ctx context.Context) ([]*relationtb.UserModel, error) {
// return u.userDB.Find(ctx, userIDs)
// },
//)
return batchGetCache2(ctx, u.rcClient, u.expireTime, userIDs, func(userID string) string {
return u.getUserInfoKey(userID)
}, func(ctx context.Context, userID string) (*relationtb.UserModel, error) {
return u.userDB.Take(ctx, userID)
})
}
func (u *UserCacheRedis) DelUsersInfo(userIDs ...string) UserCache {