本文整理匯總了Golang中github.com/orvice/shadowsocks-go/mu/user.User.GetUserInfo方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.GetUserInfo方法的具體用法?Golang User.GetUserInfo怎麽用?Golang User.GetUserInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/orvice/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()
}