mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-07 19:50:07 +08:00
cache
This commit is contained in:
parent
604ed3e3e1
commit
0793b2ab38
@ -6,7 +6,6 @@ import (
|
|||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -193,8 +192,12 @@ func (d *DataBases) ReduceFriendToCache(userID string, friendIDList ...interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) {
|
func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) {
|
||||||
result, err := redis.String(d.Exec("SMEMBERS", friendRelationCache+userID))
|
result, err := redis.Values(d.Exec("SMEMBERS", friendRelationCache+userID))
|
||||||
return strings.Split(result, " "), err
|
var userIDList []string
|
||||||
|
for _, v := range result {
|
||||||
|
userIDList = append(userIDList, v.(string))
|
||||||
|
}
|
||||||
|
return userIDList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) AddBlackUserToCache(userID string, blackList ...interface{}) error {
|
func (d *DataBases) AddBlackUserToCache(userID string, blackList ...interface{}) error {
|
||||||
@ -208,6 +211,10 @@ func (d *DataBases) ReduceBlackUserFromCache(userID string, blackList ...interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) {
|
func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) {
|
||||||
result, err := redis.String(d.Exec("SMEMBERS", blackListCache+userID))
|
result, err := redis.Values(d.Exec("SMEMBERS", blackListCache+userID))
|
||||||
return strings.Split(result, " "), err
|
var userIDList []string
|
||||||
|
for _, v := range result {
|
||||||
|
userIDList = append(userIDList, v.(string))
|
||||||
|
}
|
||||||
|
return userIDList, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user