本文整理汇总了Golang中github.com/ywengineer/shadowsocks-go/mu/user.User.GetUserInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang User.GetUserInfo方法的具体用法?Golang User.GetUserInfo怎么用?Golang User.GetUserInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ywengineer/shadowsocks-go/mu/user.User
的用法示例。
在下文中一共展示了User.GetUserInfo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: IsUserOnline
func (r *RedisClient) IsUserOnline(u user.User) bool {
key := genUserOnlineKey(u.GetUserInfo())
isExits, err := r.client.Exists(key).Result()
if err != nil {
return false
}
return isExits
}
示例2: GetUserInfo
func (r *RedisClient) GetUserInfo(u user.User) (user.UserInfo, error) {
var user user.UserInfo
val, err := r.client.Get(genUserInfoKey(u.GetUserInfo())).Result()
if err != nil {
return user, err
}
err = json.Unmarshal([]byte(val), &user)
return user, err
}
示例3: GetSize
func (r *RedisClient) GetSize(u user.User) (int64, error) {
key := genUserFlowKey(u.GetUserInfo())
isExits, err := r.client.Exists(key).Result()
if err != nil {
return 0, err
}
if !isExits {
return 0, nil
}
return r.client.Get(key).Int64()
}
示例4: IncrSize
// traffic
func (r *RedisClient) IncrSize(u user.User, size int) error {
key := genUserFlowKey(u.GetUserInfo())
incrSize := int(float32(size))
isExits, err := r.client.Exists(key).Result()
if err != nil {
return err
}
if !isExits {
return r.client.Set(key, incrSize, DefaultExpireTime).Err()
}
return r.client.IncrBy(key, int64(incrSize)).Err()
}
示例5: MarkUserOnline
func (r *RedisClient) MarkUserOnline(u user.User) error {
key := genUserOnlineKey(u.GetUserInfo())
return r.client.Set(key, "1", DefaultOnlineKeyExpireTime).Err()
}
示例6: SetSize
func (r *RedisClient) SetSize(u user.User, size int) error {
key := genUserFlowKey(u.GetUserInfo())
return r.client.Set(key, size, DefaultExpireTime).Err()
}
示例7: Del
func (r *RedisClient) Del(u user.User) error {
return r.client.Del(genUserInfoKey(u.GetUserInfo())).Err()
}
示例8: Exists
func (r *RedisClient) Exists(u user.User) (bool, error) {
return r.client.Exists(genUserInfoKey(u.GetUserInfo())).Result()
}