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.
 

76 lines
1.1 KiB

package redisrpc
import (
"github.com/golang/protobuf/proto"
)
//设置
func SAdd(key, field string, url ...string) (int64, error) {
conn, _, err := Conn(url...)
if err != nil {
return 0, err
}
defer conn.Close()
req := &SSetRequest{proto.String(key), proto.String(field), nil}
res := &SSetResponse{}
err = conn.SAdd(req, res)
if err != nil {
return 0, err
}
return res.GetRet(), nil
}
//删除
func SRem(key string, field string, url ...string) (int64, error) {
conn, _, err := Conn(url...)
if err != nil {
return 0, err
}
defer conn.Close()
req := &SSetRequest{proto.String(key), proto.String(field), nil}
res := &SSetResponse{}
err = conn.SRem(req, res)
if err != nil {
return 0, err
}
return res.GetRet(), nil
}
/**
* 全部
*/
func SIsmember(key string, field string, url ...string) (int64, error) {
conn, _, err := Conn(url...)
if err != nil {
return 0, err
}
defer conn.Close()
req := &SSetRequest{proto.String(key), proto.String(field), nil}
res := &SSetResponse{}
err = conn.SIsmember(req, res)
if err != nil {
return 0, err
}
return res.GetRet(), nil
}