From fa6ee5b87e4052b71f091fec3cc2a6046b947d85 Mon Sep 17 00:00:00 2001 From: loshiqi <553578653@qq.com> Date: Mon, 14 Nov 2022 17:52:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=89=E5=BA=8F=E9=9B=86=E5=90=88=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=AE=E7=82=B9=E5=9E=8B=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 1 - zset.go | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 2be6438..018983f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module git.tetele.net/tgo/redis -go 1.17 +go 1.16 require ( git.tetele.net/tgo/conf v0.48.0 diff --git a/go.sum b/go.sum index b107184..0f964c4 100644 --- a/go.sum +++ b/go.sum @@ -11,7 +11,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/zset.go b/zset.go index a4bd271..68128d9 100644 --- a/zset.go +++ b/zset.go @@ -42,6 +42,25 @@ func ZAdd(key string, score, member interface{}) (int64, error) { } +/* + * 存值 + * key 域 + * member 成员 + * score 分值 + */ +func ZAddFloat(key string, score, member interface{}) (float64, error) { + c := GetConn() + + reply, err := c.Do("ZADD", key, score, member) + CloseConn(c) + if err != nil { + return 0, err + } else { + return redisdb.Float64(reply, nil) + } + +} + /* * 删除hash值 */ @@ -98,6 +117,26 @@ func ZIncrBy(key string, inc, member interface{}) (int64, error) { } +/* + * 自增 + * key 域 + * member 成员 + * inc 分值 + */ +func ZIncrByFloat(key string, inc, member interface{}) (float64, error) { + c := GetConn() + + reply, err := c.Do("ZINCRBY", key, inc, member) + CloseConn(c) + + if err != nil { + return 0, err + } else { + return redisdb.Float64(reply, nil) + } + +} + func ZRange(key string, start, stop int64) ([]map[string]string, error) { c := GetConn() defer CloseConn(c)