redis rpc服务, 提供redis操作方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

34 lines
586 B

package redisrpc
import (
"github.com/golang/protobuf/proto"
)
/**
* 使用用户名查询
*/
func GetByHashKey(key, field string, url ...string) (string, error) {
var user_rpc_url string = "127.0.0.1:7953"
if len(url) > 0 && url[0] != "" {
user_rpc_url = url[0]
}
conn, _, err := DialRedisService("tcp", user_rpc_url)
if err != nil {
return "", err
}
defer conn.Close()
req := &GetHashKey{proto.String(key), proto.String(field), nil}
res := &GetResponse{}
err = conn.GetByHashKey(req, res)
if err != nil {
return "", err
}
return res.GetString_(), nil
}