Browse Source

更新

master
listen 3 years ago
parent
commit
41454d5ef7
3 changed files with 36 additions and 1 deletions
  1. +23
    -0
      hash.go
  2. +12
    -0
      hash_test.go
  3. +1
    -1
      redis.proto

+ 23
- 0
hash.go View File

@ -172,3 +172,26 @@ func HExists(key string, field string, url ...string) (int64, error) {
return res.GetRet(), nil
}
func HIncrby(key, field string,value int64, url ...string) (int64, error) {
conn, _, err := Conn(url...)
if err != nil {
return 0, err
}
defer conn.Close()
req := &HSetRequest{proto.String(key), proto.String(field), proto.String(string(value)), nil}
res := &HSetResponse{}
err = conn.HIncrby(req, res)
if err != nil {
return 0, err
}
return res.GetRet(), nil
}

+ 12
- 0
hash_test.go View File

@ -2,6 +2,7 @@ package redisrpc
import (
// "strconv"
"log"
"testing"
// "tgo/helper"
)
@ -53,3 +54,14 @@ func Test_HSet(t *testing.T) {
ret, err := HGetList("test2")
t.Log(ret, err)
}
func Test_Incrby(t *testing.T){
res,err := HIncrby("test_incr","26_26","1")
if err != nil {
log.Println(err.Error())
}
log.Println(res)
}

+ 1
- 1
redis.proto View File

@ -116,7 +116,7 @@ service RedisService {
rpc HGetList(GetRequest) returns (HGetListResponse); //get hash all
rpc HExists(HGetRequest) returns (DelResponse); //hash键是否存在
rpc Exists(GetRequest) returns (DelResponse); //
rpc HIncrby(GetRequest) returns (DelResponse); //hash数值+-1
rpc HIncrby(HSetRequest) returns (HSetResponse); //hash数值+-1
rpc SAdd(SSetRequest) returns (SSetResponse); //
rpc SIsmember(SSetRequest) returns (SSetResponse); //
rpc SRem(SSetRequest) returns (SSetResponse); //


Loading…
Cancel
Save