mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 12:08:52 +08:00
cache
This commit is contained in:
parent
0aefbc2c7d
commit
604ed3e3e1
@ -6,6 +6,7 @@ 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 (
|
||||||
@ -182,31 +183,31 @@ func (d *DataBases) GetUserInfoFromCache(userID string) (*pbCommon.UserInfo, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) AddFriendToCache(userID string, friendIDList ...interface{}) error {
|
func (d *DataBases) AddFriendToCache(userID string, friendIDList ...interface{}) error {
|
||||||
_, err := redis.String(d.Exec("SADD", friendRelationCache+userID, friendIDList...))
|
_, err := d.Exec("SADD", friendRelationCache+userID, friendIDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) ReduceFriendToCache(userID string, friendIDList ...interface{}) error {
|
func (d *DataBases) ReduceFriendToCache(userID string, friendIDList ...interface{}) error {
|
||||||
_, err := redis.String(d.Exec("SREM", friendRelationCache+userID, friendIDList...))
|
_, err := d.Exec("SREM", friendRelationCache+userID, friendIDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) {
|
func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) {
|
||||||
result, err := redis.Strings(d.Exec("SMEMBERS", friendRelationCache+userID))
|
result, err := redis.String(d.Exec("SMEMBERS", friendRelationCache+userID))
|
||||||
return result, err
|
return strings.Split(result, " "), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) AddBlackUserToCache(userID string, blackList ...interface{}) error {
|
func (d *DataBases) AddBlackUserToCache(userID string, blackList ...interface{}) error {
|
||||||
_, err := redis.String(d.Exec("SADD", blackListCache+userID, blackList...))
|
_, err := d.Exec("SADD", blackListCache+userID, blackList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) ReduceBlackUserFromCache(userID string, blackList ...interface{}) error {
|
func (d *DataBases) ReduceBlackUserFromCache(userID string, blackList ...interface{}) error {
|
||||||
_, err := redis.String(d.Exec("SREM", blackListCache+userID, blackList...))
|
_, err := d.Exec("SREM", blackListCache+userID, blackList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) {
|
func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) {
|
||||||
result, err := redis.Strings(d.Exec("SMEMBERS", blackListCache+userID))
|
result, err := redis.String(d.Exec("SMEMBERS", blackListCache+userID))
|
||||||
return result, err
|
return strings.Split(result, " "), err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user