diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index c6defb8bd..8b3cdb4c7 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -6,6 +6,7 @@ import ( pbCommon "Open_IM/pkg/proto/sdk_ws" "encoding/json" "github.com/garyburd/redigo/redis" + "strings" ) const ( @@ -192,12 +193,8 @@ func (d *DataBases) ReduceFriendToCache(userID string, friendIDList ...interface } func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) { - result, err := redis.Values(d.Exec("SMEMBERS", friendRelationCache+userID)) - var userIDList []string - for _, v := range result { - userIDList = append(userIDList, v.(string)) - } - return userIDList, err + result, err := redis.String(d.Exec("SMEMBERS", friendRelationCache+userID)) + return strings.Split(result, " "), err } func (d *DataBases) AddBlackUserToCache(userID string, blackList ...interface{}) error { @@ -211,10 +208,6 @@ func (d *DataBases) ReduceBlackUserFromCache(userID string, blackList ...interfa } func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) { - result, err := redis.Values(d.Exec("SMEMBERS", blackListCache+userID)) - var userIDList []string - for _, v := range result { - userIDList = append(userIDList, v.(string)) - } - return userIDList, err + result, err := redis.String(d.Exec("SMEMBERS", blackListCache+userID)) + return strings.Split(result, " "), err }