Compare commits
0
Commits
master
..
6ae4736285
No files matched your search
@@ -20,4 +20,3 @@
|
|||||||
.vscode
|
.vscode
|
||||||
mail_test.go
|
mail_test.go
|
||||||
*_test.go
|
*_test.go
|
||||||
!client_test.go
|
|
||||||
@@ -196,7 +196,7 @@ func (o *OwnClient) AddClient(instanceFlag string, logger *zap.Logger, instanceC
|
|||||||
clientInfo.Master = o.newClient(instanceConfig.Master)
|
clientInfo.Master = o.newClient(instanceConfig.Master)
|
||||||
}
|
}
|
||||||
if nil != instanceConfig.Slave {
|
if nil != instanceConfig.Slave {
|
||||||
clientInfo.Slave = o.newClient(instanceConfig.Slave)
|
clientInfo.Master = o.newClient(instanceConfig.Slave)
|
||||||
}
|
}
|
||||||
o.lock.Lock()
|
o.lock.Lock()
|
||||||
defer o.lock.Unlock()
|
defer o.lock.Unlock()
|
||||||
@@ -258,17 +258,17 @@ func (o *OwnClient) newClient(instanceConfig *define.Options) *redisClient.Clien
|
|||||||
Password: instanceConfig.Password,
|
Password: instanceConfig.Password,
|
||||||
// CredentialsProvider: nil,
|
// CredentialsProvider: nil,
|
||||||
// CredentialsProviderContext: nil,
|
// CredentialsProviderContext: nil,
|
||||||
MaxRetries: instanceConfig.MaxRetries,
|
MaxRetries: instanceConfig.MaxRetries,
|
||||||
MinRetryBackoff: time.Duration(instanceConfig.MinRetryBackoff) * time.Millisecond,
|
MinRetryBackoff: time.Duration(instanceConfig.MinRetryBackoff) * time.Millisecond,
|
||||||
MaxRetryBackoff: time.Duration(instanceConfig.MaxRetryBackoff) * time.Millisecond,
|
MaxRetryBackoff: time.Duration(instanceConfig.MaxRetryBackoff) * time.Millisecond,
|
||||||
DialTimeout: time.Duration(instanceConfig.DialTimeout) * time.Millisecond,
|
DialTimeout: time.Duration(instanceConfig.DialTimeout) * time.Millisecond,
|
||||||
ReadTimeout: time.Duration(instanceConfig.ReadTimeout) * time.Millisecond,
|
ReadTimeout: time.Duration(instanceConfig.ReadTimeout) * time.Millisecond,
|
||||||
WriteTimeout: time.Duration(instanceConfig.WriteTimeout) * time.Millisecond,
|
WriteTimeout: time.Duration(instanceConfig.WriteTimeout) * time.Millisecond,
|
||||||
ContextTimeoutEnabled: instanceConfig.ContextTimeoutEnabled,
|
// ContextTimeoutEnabled: instanceConfig.ContextTimeoutEnabled,
|
||||||
PoolFIFO: instanceConfig.PoolFIFO,
|
PoolFIFO: instanceConfig.PoolFIFO,
|
||||||
PoolSize: instanceConfig.PoolSize,
|
PoolSize: instanceConfig.PoolSize,
|
||||||
PoolTimeout: time.Duration(instanceConfig.PoolTimeout) * time.Millisecond,
|
PoolTimeout: time.Duration(instanceConfig.PoolTimeout) * time.Millisecond,
|
||||||
MinIdleConns: instanceConfig.MinIdleConn,
|
MinIdleConns: instanceConfig.MinIdleConn,
|
||||||
// MaxIdleConns: instanceConfig.MaxIdleConn,
|
// MaxIdleConns: instanceConfig.MaxIdleConn,
|
||||||
// MaxActiveConns: instanceConfig.MaxActiveConn,
|
// MaxActiveConns: instanceConfig.MaxActiveConn,
|
||||||
// ConnMaxIdleTime: time.Duration(instanceConfig.ConnMaxIdleTime) * time.Second,
|
// ConnMaxIdleTime: time.Duration(instanceConfig.ConnMaxIdleTime) * time.Second,
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
package redis
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"git.zhangdeman.cn/zhangdeman/redis/define"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestAddClientKeepsMasterAndSlaveSeparate(t *testing.T) {
|
|
||||||
client := &OwnClient{
|
|
||||||
lock: &sync.RWMutex{},
|
|
||||||
instanceTable: map[string]*define.ClientInfo{},
|
|
||||||
whiteCommandTable: map[string]bool{},
|
|
||||||
logger: zap.NewNop(),
|
|
||||||
}
|
|
||||||
err := client.AddClient("main", zap.NewNop(), &define.Config{
|
|
||||||
Master: &define.Options{Addr: "master.example:6379"},
|
|
||||||
Slave: &define.Options{Addr: "slave.example:6379"},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
info := client.GetRealClient("main")
|
|
||||||
if info.MasterClient() == nil || info.MasterClient().Options().Addr != "master.example:6379" {
|
|
||||||
t.Fatal("master connection was overwritten")
|
|
||||||
}
|
|
||||||
if info.SlaveClient() == nil || info.SlaveClient().Options().Addr != "slave.example:6379" {
|
|
||||||
t.Fatal("slave connection was not retained")
|
|
||||||
}
|
|
||||||
_ = info.MasterClient().Close()
|
|
||||||
_ = info.SlaveClient().Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewClientPassesContextTimeoutEnabled(t *testing.T) {
|
|
||||||
client := &OwnClient{}
|
|
||||||
redisClient := client.newClient(&define.Options{
|
|
||||||
Addr: "127.0.0.1:6379",
|
|
||||||
ContextTimeoutEnabled: true,
|
|
||||||
})
|
|
||||||
t.Cleanup(func() {
|
|
||||||
_ = redisClient.Close()
|
|
||||||
})
|
|
||||||
|
|
||||||
if !redisClient.Options().ContextTimeoutEnabled {
|
|
||||||
t.Fatal("context timeout option was not passed to go-redis")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,12 +5,12 @@ go 1.24.0
|
|||||||
toolchain go1.24.2
|
toolchain go1.24.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260413082525-fb90982b1256
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260126034341-a8525cc7388b
|
||||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a
|
||||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20260321023345-6c6e467e3a14
|
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20251225094759-09c64ba2541c
|
||||||
github.com/go-redis/redismock/v9 v9.2.0
|
github.com/go-redis/redismock/v9 v9.2.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/redis/go-redis/v9 v9.18.0
|
github.com/redis/go-redis/v9 v9.17.3
|
||||||
go.uber.org/zap v1.27.1
|
go.uber.org/zap v1.27.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
@@ -28,7 +28,6 @@ require (
|
|||||||
github.com/tidwall/gjson v1.18.0 // indirect
|
github.com/tidwall/gjson v1.18.0 // indirect
|
||||||
github.com/tidwall/match v1.2.0 // indirect
|
github.com/tidwall/match v1.2.0 // indirect
|
||||||
github.com/tidwall/pretty v1.2.1 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
go.uber.org/atomic v1.11.0 // indirect
|
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.1 // indirect
|
gopkg.in/ini.v1 v1.67.1 // indirect
|
||||||
)
|
)
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260127050054-349cdcde813a h1:4apFwfRDdGBkSybcLWzjIYjz8i6yR28Wyt7iBK3K+Po=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71 h1:ivFHFIHbviWLvyQyCKw0C0Nd8hfobp9lPpKbbxdTtDY=
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260127050054-349cdcde813a/go.mod h1:5p8CEKGBxi7qPtTXDI3HDmqKAfIm5i/aBWdrbkbdNjc=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71/go.mod h1:5p8CEKGBxi7qPtTXDI3HDmqKAfIm5i/aBWdrbkbdNjc=
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260413082525-fb90982b1256 h1:zYkRoH86j+4BoVGCWUY6zA+FIQNmul/c8whmmYK3bT4=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260126034341-a8525cc7388b h1:Mt4pZwdeDlmKiTyiAdmeH35LvjFfljXxJD3AKnhtvhQ=
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260413082525-fb90982b1256/go.mod h1:5p8CEKGBxi7qPtTXDI3HDmqKAfIm5i/aBWdrbkbdNjc=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260126034341-a8525cc7388b/go.mod h1:5p8CEKGBxi7qPtTXDI3HDmqKAfIm5i/aBWdrbkbdNjc=
|
||||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20251013024601-da007da2fb42 h1:VjYrb4adud7FHeiYS9XA0B/tOaJjfRejzQAlwimrrDc=
|
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20251013024601-da007da2fb42 h1:VjYrb4adud7FHeiYS9XA0B/tOaJjfRejzQAlwimrrDc=
|
||||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20251013024601-da007da2fb42/go.mod h1:VHb9qmhaPDAQDcS6vUiDCamYjZ4R5lD1XtVsh55KsMI=
|
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20251013024601-da007da2fb42/go.mod h1:VHb9qmhaPDAQDcS6vUiDCamYjZ4R5lD1XtVsh55KsMI=
|
||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20260112135254-c9ba29f9f674 h1:75JJ09HPqWi9qm7XD+vV6p5TaCMQgDsae/EbsLiE1t4=
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20260112135254-c9ba29f9f674 h1:75JJ09HPqWi9qm7XD+vV6p5TaCMQgDsae/EbsLiE1t4=
|
||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20260112135254-c9ba29f9f674/go.mod h1:EXrvDs830GzqhDNTR5TgKVbT3ADRgyUb2pFerwF4rLc=
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20260112135254-c9ba29f9f674/go.mod h1:EXrvDs830GzqhDNTR5TgKVbT3ADRgyUb2pFerwF4rLc=
|
||||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a h1:IGUsWz204BTQlD2l4kenlwJQS4Av2RS2kfUHZ5QVrmw=
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a h1:IGUsWz204BTQlD2l4kenlwJQS4Av2RS2kfUHZ5QVrmw=
|
||||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a/go.mod h1:OKI+RVVfRTUf/ox9uDMydtos2YDFr+/UuU4FFZKgPYY=
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a/go.mod h1:OKI+RVVfRTUf/ox9uDMydtos2YDFr+/UuU4FFZKgPYY=
|
||||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20260321023345-6c6e467e3a14 h1:YtOciqKZVCtGt5YMMDEmINzRXK3ZE9mscXSkSKwK8/o=
|
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20251225094759-09c64ba2541c h1:lTShwLIIBojEInQlQYmKvpoio5Srasn05bPyBIEXBsY=
|
||||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20260321023345-6c6e467e3a14/go.mod h1:oSmLgHs4EausBSmH4GdpGUtjubPek8hLXTAUc4cPCb0=
|
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20251225094759-09c64ba2541c/go.mod h1:oSmLgHs4EausBSmH4GdpGUtjubPek8hLXTAUc4cPCb0=
|
||||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
@@ -35,8 +35,6 @@ github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25d
|
|||||||
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mozillazg/go-pinyin v0.21.0 h1:Wo8/NT45z7P3er/9YSLHA3/kjZzbLz5hR7i+jGeIGao=
|
github.com/mozillazg/go-pinyin v0.21.0 h1:Wo8/NT45z7P3er/9YSLHA3/kjZzbLz5hR7i+jGeIGao=
|
||||||
@@ -51,8 +49,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
|
github.com/redis/go-redis/v9 v9.17.3 h1:fN29NdNrE17KttK5Ndf20buqfDZwGNgoUr9qjl1DQx4=
|
||||||
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
|
github.com/redis/go-redis/v9 v9.17.3/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
|
||||||
github.com/sbabiv/xml2map v1.2.1 h1:1lT7t0hhUvXZCkdxqtq4n8/ZCnwLWGq4rDuDv5XOoFE=
|
github.com/sbabiv/xml2map v1.2.1 h1:1lT7t0hhUvXZCkdxqtq4n8/ZCnwLWGq4rDuDv5XOoFE=
|
||||||
github.com/sbabiv/xml2map v1.2.1/go.mod h1:2TPoAfcaM7+Sd4iriPvzyntb2mx7GY+kkQpB/GQa/eo=
|
github.com/sbabiv/xml2map v1.2.1/go.mod h1:2TPoAfcaM7+Sd4iriPvzyntb2mx7GY+kkQpB/GQa/eo=
|
||||||
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
|
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
|
||||||
@@ -78,10 +76,6 @@ github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
|
|||||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
|
||||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
|
||||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
|
||||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
|
|||||||
-31
@@ -111,34 +111,3 @@ func (w *wrapper) BLPop(ctx context.Context, instanceFlag string, key []string,
|
|||||||
paramList = append(paramList, timeout)
|
paramList = append(paramList, timeout)
|
||||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandBlpop, paramList...)
|
return Client.Exec(ctx, instanceFlag, consts.RedisCommandBlpop, paramList...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZRangeByScore 按分值获取数据
|
|
||||||
func (w *wrapper) ZRangeByScore(ctx context.Context, instanceFlag string, key string, startScore int64, endScore int64) *define.RedisResult {
|
|
||||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandZrangeByScore, key, startScore, endScore, "WITHSCORES")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ZRemRangeByScore 删除集合中分值区间的数据
|
|
||||||
func (w *wrapper) ZRemRangeByScore(ctx context.Context, instanceFlag string, key string, startScore int64, endScore int64) *define.RedisResult {
|
|
||||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandZRemRangeByScore, key, startScore, endScore)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ZRangeAndRemByScore 获取集合到期数据并删除
|
|
||||||
// 本质: ZRange + ZRemRangeByScore
|
|
||||||
func (w *wrapper) ZRangeAndRemByScore(ctx context.Context, instanceFlag string, key string, startScore int64, endScore int64) *define.RedisResult {
|
|
||||||
rangeRes := w.ZRangeByScore(ctx, instanceFlag, key, startScore, endScore)
|
|
||||||
if nil == rangeRes.Err {
|
|
||||||
// 读取成功, 删除
|
|
||||||
w.ZRemRangeByScore(ctx, instanceFlag, key, startScore, endScore)
|
|
||||||
}
|
|
||||||
return rangeRes
|
|
||||||
}
|
|
||||||
|
|
||||||
// ZAdd ...
|
|
||||||
func (w *wrapper) ZAdd(ctx context.Context, instanceFlag string, key string, score int64, data any) *define.RedisResult {
|
|
||||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandZadd, key, score, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ZAddWithOption ...
|
|
||||||
func (w *wrapper) ZAddWithOption(ctx context.Context, instanceFlag string, key string, option string, score int64, data any) *define.RedisResult {
|
|
||||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandZadd, key, option, score, data)
|
|
||||||
}
|
|
||||||