From 4a8da13dd0a895865a2bc232ef42113cb18e231c Mon Sep 17 00:00:00 2001 From: listen <494177603@qq.com> Date: Thu, 11 Nov 2021 19:59:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5hincrby=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hash.go | 5 +++-- hash_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hash.go b/hash.go index 3400ca0..ac3a2fe 100644 --- a/hash.go +++ b/hash.go @@ -3,6 +3,7 @@ package redisrpc import ( "encoding/json" "log" + "strconv" "github.com/golang/protobuf/proto" ) @@ -174,7 +175,7 @@ func HExists(key string, field string, url ...string) (int64, error) { } -func HIncrby(key, field string,value int64, url ...string) (int64, error) { +func HIncrby(key, field string,value int, url ...string) (int64, error) { conn, _, err := Conn(url...) @@ -183,7 +184,7 @@ func HIncrby(key, field string,value int64, url ...string) (int64, error) { } defer conn.Close() - req := &HSetRequest{proto.String(key), proto.String(field), proto.String(string(value)), nil} + req := &HSetRequest{proto.String(key), proto.String(field), proto.String(strconv.Itoa(value)), nil} res := &HSetResponse{} diff --git a/hash_test.go b/hash_test.go index ba96dfb..38f2f78 100644 --- a/hash_test.go +++ b/hash_test.go @@ -57,7 +57,7 @@ func Test_HSet(t *testing.T) { func Test_Incrby(t *testing.T){ - res,err := HIncrby("test_incr","26_26","1") + res,err := HIncrby("test_incr","26_26",2) if err != nil { log.Println(err.Error())