Browse Source

加入hincrby方法

master v0.6.1
listen 2 years ago
parent
commit
4a8da13dd0
2 changed files with 4 additions and 3 deletions
  1. +3
    -2
      hash.go
  2. +1
    -1
      hash_test.go

+ 3
- 2
hash.go View File

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


+ 1
- 1
hash_test.go View File

@ -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())


Loading…
Cancel
Save