feat: 支持 BRPOP BLPOP
This commit is contained in:
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.24.0
|
||||
toolchain go1.24.2
|
||||
|
||||
require (
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260126034341-a8525cc7388b
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a
|
||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20251225094759-09c64ba2541c
|
||||
github.com/go-redis/redismock/v9 v9.2.0
|
||||
|
||||
2
go.sum
2
go.sum
@@ -1,5 +1,7 @@
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71 h1:ivFHFIHbviWLvyQyCKw0C0Nd8hfobp9lPpKbbxdTtDY=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71/go.mod h1:5p8CEKGBxi7qPtTXDI3HDmqKAfIm5i/aBWdrbkbdNjc=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260126034341-a8525cc7388b h1:Mt4pZwdeDlmKiTyiAdmeH35LvjFfljXxJD3AKnhtvhQ=
|
||||
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/go.mod h1:VHb9qmhaPDAQDcS6vUiDCamYjZ4R5lD1XtVsh55KsMI=
|
||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20260112135254-c9ba29f9f674 h1:75JJ09HPqWi9qm7XD+vV6p5TaCMQgDsae/EbsLiE1t4=
|
||||
|
||||
20
wrapper.go
20
wrapper.go
@@ -91,3 +91,23 @@ func (w *wrapper) HSet(ctx context.Context, instanceFlag string, key string, fie
|
||||
func (w *wrapper) HDel(ctx context.Context, instanceFlag string, key string, fieldList ...string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandHdel, key, strings.Join(fieldList, " "))
|
||||
}
|
||||
|
||||
// BRPop ...
|
||||
func (w *wrapper) BRPop(ctx context.Context, instanceFlag string, key []string, timeout int64) *define.RedisResult {
|
||||
paramList := []any{}
|
||||
for _, item := range key {
|
||||
paramList = append(paramList, item)
|
||||
}
|
||||
paramList = append(paramList, timeout)
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandBrpop, paramList...)
|
||||
}
|
||||
|
||||
// BLPop ...
|
||||
func (w *wrapper) BLPop(ctx context.Context, instanceFlag string, key []string, timeout int64) *define.RedisResult {
|
||||
paramList := []any{}
|
||||
for _, item := range key {
|
||||
paramList = append(paramList, item)
|
||||
}
|
||||
paramList = append(paramList, timeout)
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandBlpop, paramList...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user