Browse Source

有序集合增加浮点型写入

master v1.8.0
loshiqi 2 years ago
parent
commit
fa6ee5b87e
3 changed files with 40 additions and 2 deletions
  1. +1
    -1
      go.mod
  2. +0
    -1
      go.sum
  3. +39
    -0
      zset.go

+ 1
- 1
go.mod View File

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


+ 0
- 1
go.sum View File

@ -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=

+ 39
- 0
zset.go View File

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


Loading…
Cancel
Save