2 Commits

5 changed files with 29 additions and 1 deletions
Split View
  1. +1
    -0
      go.mod
  2. +2
    -0
      go.sum
  3. +1
    -0
      redis.proto
  4. +24
    -0
      string.go
  5. +1
    -1
      string_test.go

+ 1
- 0
go.mod View File

@ -4,6 +4,7 @@ go 1.14
require (
git.tetele.net/tgo/conf v0.35.3
git.tetele.net/tgo/helper v0.2.6
github.com/chai2010/protorpc v1.0.0
github.com/golang/protobuf v1.5.2
)

+ 2
- 0
go.sum View File

@ -2,6 +2,8 @@ git.tetele.net/tgo/conf v0.25.0 h1:fopDch45xw/di5fLvvzwltFiGiXrilMobZwQNO678Wo=
git.tetele.net/tgo/conf v0.25.0/go.mod h1:DogEBvxG2fGdukpoobTVFE2b4Fd5OTE9FJ3Xetyn47E=
git.tetele.net/tgo/conf v0.35.3 h1:OQEa87qN5bAbscjMhaoTRinLnv8xZg1WErl5JXgFZco=
git.tetele.net/tgo/conf v0.35.3/go.mod h1:AWVIBEDE5dtotthUgR0SWaR2Qa6/f+O5WQ3s7Tj8q7A=
git.tetele.net/tgo/helper v0.2.6 h1:JC+N+If/bGvcwuUSklva17YDNtKBV2Qpvl5RQpMySOY=
git.tetele.net/tgo/helper v0.2.6/go.mod h1:89mQwyfqZ+t8YXiVwzSxA70gLlUNqoZGDEUxvV46jXk=
github.com/chai2010/protorpc v1.0.0 h1:aJ45G9sl1utSKo35EqnBSTs5jqTpdJDJAuZMMYPAtFo=
github.com/chai2010/protorpc v1.0.0/go.mod h1:woR3WwjaQDqFjlzdVsFEKiK5Ur12QL8mYxVPjfr5z54=
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=


+ 1
- 0
redis.proto View File

@ -130,6 +130,7 @@ service RedisService {
rpc SAdd(SSetRequest) returns (SSetResponse); //
rpc SIsmember(SSetRequest) returns (SSetResponse); //
rpc SRem(SSetRequest) returns (SSetResponse); //
rpc SCard(SSetRequest) returns (SSetResponse); //
rpc LLpush(LSetRequest) returns (LSetResponse); //
rpc LRpush(LSetRequest) returns (LSetResponse); //
rpc LRange(LRangeRequest) returns (HGetListResponse); //


+ 24
- 0
string.go View File

@ -95,3 +95,27 @@ func Exists(key string, url ...string)(int64, error){
return res.GetRet(), nil
}
//设置如果不存在
func SetNx(key, value string, ttl int64, url ...string) (int64, error) {
conn, _, err := Conn(url...)
if err != nil {
return 0, err
}
defer conn.Close()
req := &SetRequest{proto.String(key), proto.String(value), proto.Int64(ttl), nil}
res := &DelResponse{}
err = conn.SetNx(req, res)
if err != nil {
return 0, err
}
return res.GetRet(), nil
}

+ 1
- 1
string_test.go View File

@ -27,4 +27,4 @@ func Test_Del(t *testing.T) {
t.Log(c)
t.Log(err)
}
}

Loading…
Cancel
Save