|
|
- package redisrpc
-
- import (
- "git.tetele.net/tgo/conf"
- "github.com/golang/protobuf/proto"
- )
-
- /**
- * 使用用户名查询
- */
- func HGetString(key, field string, url ...string) (string, error) {
-
- var rpc_url string = "127.0.0.1:" + conf.REDIS_RPC_PORT
- if len(url) > 0 && url[0] != "" {
- rpc_url = url[0]
- }
-
- conn, _, err := DialRedisService("tcp", rpc_url)
- if err != nil {
- return "", err
- }
- defer conn.Close()
-
- req := &HGetRequest{proto.String(key), proto.String(field), nil}
-
- res := &GetStringResponse{}
-
- err = conn.HGet(req, res)
-
- if err != nil {
- return "", err
- }
-
- return res.GetValue(), nil
- }
|