package redisdb import ( "context" "encoding/json" "errors" ) // GetValueByKey ... func (s Server) GetValueByKey(ctx context.Context, key string) string { cmd := s.rdb.Get(ctx, key) if cmd == nil { return "" } value, _ := cmd.Result() return value } // GetValueByKeyWithBindData ... func (s Server) GetValueByKeyWithBindData(ctx context.Context, key string, result interface{}) error { v := s.GetValueByKey(ctx, key) if v == "" { return errors.New("key not found") } return json.Unmarshal([]byte(v), &result) }