示例#1
0
func Load(id string) *TraceT {
	body, err := redis.Get(id)
	if err != nil {
		return nil
	}
	t := &TraceT{}
	if err := json.Unmarshal([]byte(body), t); err != nil {
		return nil
	}
	g_traceMgr.Set(t.ID, t)
	return t
}
示例#2
0
文件: state.go 项目: wxaxiaoyao/linux
func GetUserState(uid uint64) (*UserState, error) {
	us := &UserState{Uid: uid}
	key := fmt.Sprintf("user_state_%v", us.Uid)
	val, err := redis_.Get(key)
	if err != nil {
		if errors.ERR_NO_DATA.Equal(err) {
			return us, nil
		}
		return us, errors.As(err, key)
	}
	if err := json.Unmarshal([]byte(val), us); err != nil {
		return us, errors.As(err, val)
	}
	return us, nil
}
示例#3
0
文件: token.go 项目: wxaxiaoyao/linux
func GetUserToken(uid uint64) (string, error) {
	return redis.Get(fmt.Sprint(USER_TOKEN, uid))
}