|
|
- 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
- }
|