Compare commits
0
Commits
master
..
ec5f5f0161
No files matched your search
@@ -20,4 +20,3 @@
|
||||
.vscode
|
||||
mail_test.go
|
||||
*_test.go
|
||||
!client_test.go
|
||||
@@ -10,9 +10,7 @@ package abstract
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"git.zhangdeman.cn/zhangdeman/redis/define"
|
||||
"github.com/go-redis/redismock/v9"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -22,13 +20,11 @@ import (
|
||||
//
|
||||
// Date : 15:09 2024/6/18
|
||||
type IRedisClient interface {
|
||||
GetRealClient(instanceFlag string) *define.ClientInfo // 获取客户端连接
|
||||
GetRealClientWithError(instanceFlag string) (*define.ClientInfo, error) // 获取带error的客户端连接
|
||||
AddClient(instanceFlag string, logger *zap.Logger, instanceConfig *define.Config) error // 添加新的客户端连接
|
||||
RemoveClient(instanceFlag string) // 移除一个客户端连接
|
||||
SetLogger(loggerInstance *zap.Logger, extraLogFieldList []string) // 设置日志实例, 全局生效, 而非针对某一个实例
|
||||
Exec(ctx context.Context, instanceFlag string, command consts.RedisCmd, args ...any) *define.RedisResult // 执行任意命令
|
||||
SetCommandWhiteList(command []consts.RedisCmd) // 设置命令的白名单,全局生效, 而非单独针对某一个实例
|
||||
SetMockMode() // 设置mock模式, 这是单元测试专用的, 生产环境不要使用!!!!!!
|
||||
GetMockInstance() redismock.ClientMock // 数据mock实例
|
||||
GetRealClient(instanceFlag string) *define.ClientInfo // 获取客户端连接
|
||||
GetRealClientWithError(instanceFlag string) (*define.ClientInfo, error) // 获取带error的客户端连接
|
||||
AddClient(instanceFlag string, instanceConfig *define.Config) error // 添加新的客户端连接
|
||||
RemoveClient(instanceFlag string) // 移除一个客户端连接
|
||||
SetLogger(loggerInstance *zap.Logger, extraLogFieldList []string) // 设置日志实例, 全局生效, 而非针对某一个实例
|
||||
Exec(ctx context.Context, instanceFlag string, command string, args ...any) *define.RedisResult // 执行任意命令
|
||||
SetCommandWhiteList(command []string) // 设置命令的白名单,全局生效, 而非单独针对某一个实例
|
||||
}
|
||||
@@ -9,17 +9,14 @@ package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper/op_any"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper/op_array"
|
||||
"github.com/go-redis/redismock/v9"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/redis/abstract"
|
||||
"git.zhangdeman.cn/zhangdeman/redis/define"
|
||||
wrapperOperate "git.zhangdeman.cn/zhangdeman/wrapper"
|
||||
"github.com/pkg/errors"
|
||||
redisClient "github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
@@ -34,7 +31,6 @@ func init() {
|
||||
lock: &sync.RWMutex{},
|
||||
instanceTable: make(map[string]*define.ClientInfo),
|
||||
whiteCommandTable: make(map[string]bool),
|
||||
logger: zap.NewNop(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +40,6 @@ type OwnClient struct {
|
||||
whiteCommandTable map[string]bool
|
||||
logger *zap.Logger
|
||||
extraLogFieldList []string
|
||||
mockMode bool
|
||||
mockInstance redismock.ClientMock
|
||||
mockClient *redisClient.Client
|
||||
}
|
||||
|
||||
func (o *OwnClient) isAllowCommand(command string) bool {
|
||||
@@ -65,7 +58,11 @@ func (o *OwnClient) isAllowCommand(command string) bool {
|
||||
}
|
||||
|
||||
// Exec 执行命令
|
||||
func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command consts.RedisCmd, args ...any) *define.RedisResult {
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:05 2024/6/19
|
||||
func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command string, args ...any) *define.RedisResult {
|
||||
if nil == ctx {
|
||||
ctx = context.Background()
|
||||
}
|
||||
@@ -74,11 +71,11 @@ func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command const
|
||||
)
|
||||
|
||||
cmdParamList := []any{
|
||||
strings.ToLower(command.String()), // redis 命令不区分大小写, 统一使用小写
|
||||
command,
|
||||
}
|
||||
argStrList := make([]string, 0)
|
||||
for _, itemArg := range args {
|
||||
argStrList = append(argStrList, op_any.AnyDataType(itemArg).ToString())
|
||||
argStrList = append(argStrList, wrapperOperate.AnyDataType(itemArg).ToString().Value())
|
||||
cmdParamList = append(cmdParamList, itemArg)
|
||||
}
|
||||
res := &define.RedisResult{
|
||||
@@ -94,11 +91,15 @@ func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command const
|
||||
defer func() {
|
||||
res.FinishTime = time.Now().UnixMilli()
|
||||
res.UsedTime = res.FinishTime - res.StartTime
|
||||
if nil == o.logger {
|
||||
// 未注入日志实例
|
||||
return
|
||||
}
|
||||
logDataList := []zap.Field{
|
||||
zap.Int64("start_time", res.StartTime),
|
||||
zap.Int64("finish_time", res.FinishTime),
|
||||
zap.Int64("used_time", res.UsedTime),
|
||||
zap.String("command", res.Command.String()),
|
||||
zap.String("command", res.Command),
|
||||
zap.String("arg_list", strings.Join(res.ArgList, " ")),
|
||||
zap.String("execute_result", res.Result),
|
||||
zap.Error(res.Err),
|
||||
@@ -106,25 +107,10 @@ func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command const
|
||||
for _, item := range o.extraLogFieldList {
|
||||
logDataList = append(logDataList, zap.Any(item, ctx.Value(item)))
|
||||
}
|
||||
isError := false
|
||||
if res.Err != nil && res.Err != redisClient.Nil {
|
||||
isError = true
|
||||
}
|
||||
loggerInstance := o.logger
|
||||
if nil != instance && nil != instance.Logger {
|
||||
loggerInstance = instance.Logger
|
||||
}
|
||||
if isError {
|
||||
loggerInstance.Error(
|
||||
"Redis 命令执行失败",
|
||||
logDataList...,
|
||||
)
|
||||
} else {
|
||||
loggerInstance.Info(
|
||||
"Redis 命令执行成功",
|
||||
logDataList...,
|
||||
)
|
||||
}
|
||||
o.logger.Info(
|
||||
"Redis命令执行记录",
|
||||
logDataList...,
|
||||
)
|
||||
}()
|
||||
if instance, res.Err = o.GetRealClientWithError(instanceFlag); nil != res.Err {
|
||||
return res
|
||||
@@ -150,16 +136,20 @@ func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command const
|
||||
if res.Err = cmdRes.Err(); nil != res.Err {
|
||||
return res
|
||||
}
|
||||
res.Result = op_any.AnyDataType(cmdRes.Val()).ToString()
|
||||
res.Result = wrapperOperate.AnyDataType(cmdRes.Val()).ToString().Value()
|
||||
return res
|
||||
}
|
||||
|
||||
// SetCommandWhiteList 设置命令白名单, 空 或者 包含 * 则认为所有命令均允许执行
|
||||
func (o *OwnClient) SetCommandWhiteList(commandList []consts.RedisCmd) {
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:02 2024/6/19
|
||||
func (o *OwnClient) SetCommandWhiteList(commandList []string) {
|
||||
o.lock.Lock()
|
||||
defer o.lock.Unlock()
|
||||
for _, itemCommand := range commandList {
|
||||
o.whiteCommandTable[strings.ToLower(strings.TrimSpace(itemCommand.String()))] = true
|
||||
o.whiteCommandTable[strings.ToLower(strings.TrimSpace(itemCommand))] = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,14 +169,13 @@ func (o *OwnClient) GetRealClientWithError(instanceFlag string) (*define.ClientI
|
||||
return instance, nil
|
||||
}
|
||||
|
||||
func (o *OwnClient) AddClient(instanceFlag string, logger *zap.Logger, instanceConfig *define.Config) error {
|
||||
func (o *OwnClient) AddClient(instanceFlag string, instanceConfig *define.Config) error {
|
||||
if nil == instanceConfig.Master && !instanceConfig.ReadOnly {
|
||||
// 不是只读, 则要求 主库配置 和 从库配置都要存在
|
||||
return errors.New(instanceFlag + " : master config is nil")
|
||||
}
|
||||
|
||||
clientInfo := &define.ClientInfo{
|
||||
Logger: logger,
|
||||
ReadOnly: instanceConfig.ReadOnly,
|
||||
Master: nil,
|
||||
Slave: nil,
|
||||
@@ -196,7 +185,7 @@ func (o *OwnClient) AddClient(instanceFlag string, logger *zap.Logger, instanceC
|
||||
clientInfo.Master = o.newClient(instanceConfig.Master)
|
||||
}
|
||||
if nil != instanceConfig.Slave {
|
||||
clientInfo.Slave = o.newClient(instanceConfig.Slave)
|
||||
clientInfo.Master = o.newClient(instanceConfig.Slave)
|
||||
}
|
||||
o.lock.Lock()
|
||||
defer o.lock.Unlock()
|
||||
@@ -216,35 +205,28 @@ func (o *OwnClient) SetLogger(loggerInstance *zap.Logger, extraLogFieldList []st
|
||||
}
|
||||
|
||||
// isWriteCommand 判断是否写命令
|
||||
func (o *OwnClient) isWriteCommand(command consts.RedisCmd) bool {
|
||||
return op_array.ArrayType[string]([]string{
|
||||
consts.RedisCommandDel.String(),
|
||||
consts.RedisCommandSet.String(),
|
||||
consts.RedisCommandLpush.String(),
|
||||
consts.RedisCommandRpush.String(),
|
||||
consts.RedisCommandMSet.String(),
|
||||
consts.RedisCommandPublish.String(),
|
||||
consts.RedisCommandPsubScribe.String(),
|
||||
}).Has(strings.ToUpper(command.String())) >= 0
|
||||
}
|
||||
|
||||
// SetMockMode 启用mock, 非单元测试不要使用!!!!!!!!
|
||||
func (o *OwnClient) SetMockMode() {
|
||||
o.mockMode = true
|
||||
o.mockClient, o.mockInstance = redismock.NewClientMock()
|
||||
}
|
||||
|
||||
// GetMockInstance 获取mock实例
|
||||
func (o *OwnClient) GetMockInstance() redismock.ClientMock {
|
||||
return o.mockInstance
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:22 2024/10/8
|
||||
func (o *OwnClient) isWriteCommand(command string) bool {
|
||||
return wrapperOperate.ArrayType([]string{
|
||||
consts.RedisCommandDel,
|
||||
consts.RedisCommandSet,
|
||||
consts.RedisCommandLpush,
|
||||
consts.RedisCommandRpush,
|
||||
consts.RedisCommandMSet,
|
||||
consts.RedisCommandPublish,
|
||||
consts.RedisCommandPsubScribe,
|
||||
}).Has(strings.ToUpper(command)) >= 0
|
||||
}
|
||||
|
||||
// newClient 获取客户端连接
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:12 2024/10/8
|
||||
func (o *OwnClient) newClient(instanceConfig *define.Options) *redisClient.Client {
|
||||
if o.mockMode {
|
||||
// mock模式下, 直接返回mock实例
|
||||
return o.mockClient
|
||||
}
|
||||
return redisClient.NewClient(&redisClient.Options{
|
||||
DB: instanceConfig.DB,
|
||||
Addr: instanceConfig.Addr,
|
||||
@@ -258,17 +240,17 @@ func (o *OwnClient) newClient(instanceConfig *define.Options) *redisClient.Clien
|
||||
Password: instanceConfig.Password,
|
||||
// CredentialsProvider: nil,
|
||||
// CredentialsProviderContext: nil,
|
||||
MaxRetries: instanceConfig.MaxRetries,
|
||||
MinRetryBackoff: time.Duration(instanceConfig.MinRetryBackoff) * time.Millisecond,
|
||||
MaxRetryBackoff: time.Duration(instanceConfig.MaxRetryBackoff) * time.Millisecond,
|
||||
DialTimeout: time.Duration(instanceConfig.DialTimeout) * time.Millisecond,
|
||||
ReadTimeout: time.Duration(instanceConfig.ReadTimeout) * time.Millisecond,
|
||||
WriteTimeout: time.Duration(instanceConfig.WriteTimeout) * time.Millisecond,
|
||||
ContextTimeoutEnabled: instanceConfig.ContextTimeoutEnabled,
|
||||
PoolFIFO: instanceConfig.PoolFIFO,
|
||||
PoolSize: instanceConfig.PoolSize,
|
||||
PoolTimeout: time.Duration(instanceConfig.PoolTimeout) * time.Millisecond,
|
||||
MinIdleConns: instanceConfig.MinIdleConn,
|
||||
MaxRetries: instanceConfig.MaxRetries,
|
||||
MinRetryBackoff: time.Duration(instanceConfig.MinRetryBackoff) * time.Millisecond,
|
||||
MaxRetryBackoff: time.Duration(instanceConfig.MaxRetryBackoff) * time.Millisecond,
|
||||
DialTimeout: time.Duration(instanceConfig.DialTimeout) * time.Millisecond,
|
||||
ReadTimeout: time.Duration(instanceConfig.ReadTimeout) * time.Millisecond,
|
||||
WriteTimeout: time.Duration(instanceConfig.WriteTimeout) * time.Millisecond,
|
||||
// ContextTimeoutEnabled: instanceConfig.ContextTimeoutEnabled,
|
||||
PoolFIFO: instanceConfig.PoolFIFO,
|
||||
PoolSize: instanceConfig.PoolSize,
|
||||
PoolTimeout: time.Duration(instanceConfig.PoolTimeout) * time.Millisecond,
|
||||
MinIdleConns: instanceConfig.MinIdleConn,
|
||||
// MaxIdleConns: instanceConfig.MaxIdleConn,
|
||||
// MaxActiveConns: instanceConfig.MaxActiveConn,
|
||||
// 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")
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -7,10 +7,7 @@
|
||||
// Date : 2024-06-18 16:12
|
||||
package define
|
||||
|
||||
import (
|
||||
redisClient "github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
import redisClient "github.com/redis/go-redis/v9"
|
||||
|
||||
type Options struct {
|
||||
DB int `json:"db" yaml:"db" ini:"db" toml:"db"` // 选择的数据库序号
|
||||
@@ -64,7 +61,6 @@ type Config struct {
|
||||
//
|
||||
// Date : 16:06 2024/10/8
|
||||
type ClientInfo struct {
|
||||
Logger *zap.Logger // 日志实例
|
||||
ReadOnly bool // 是否只读
|
||||
Master *redisClient.Client // 主库连接
|
||||
Slave *redisClient.Client // 从库连接
|
||||
|
||||
+8
-10
@@ -7,20 +7,18 @@
|
||||
// Date : 2024-06-19 10:49
|
||||
package define
|
||||
|
||||
import "git.zhangdeman.cn/zhangdeman/consts"
|
||||
|
||||
// RedisResult redis名玲玲执行结果
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:50 2024/6/19
|
||||
type RedisResult struct {
|
||||
InstanceFlag string `json:"instance_flag"` // 实例标识
|
||||
StartTime int64 `json:"start_time"` // 开始执行时间, 单位 : ms
|
||||
FinishTime int64 `json:"finish_time"` // 完成执行时间, 单位 : ms
|
||||
UsedTime int64 `json:"used_time"` // 执行耗时, 单位 : ms
|
||||
Result string `json:"result"` // 执行结果
|
||||
Command consts.RedisCmd `json:"command"` // 执行的命令
|
||||
ArgList []string `json:"arg_list"` // 参数列表
|
||||
Err error `json:"-"` // 失败信息
|
||||
InstanceFlag string `json:"instance_flag"` // 实例标识
|
||||
StartTime int64 `json:"start_time"` // 开始执行时间, 单位 : ms
|
||||
FinishTime int64 `json:"finish_time"` // 完成执行时间, 单位 : ms
|
||||
UsedTime int64 `json:"used_time"` // 执行耗时, 单位 : ms
|
||||
Result string `json:"result"` // 执行结果
|
||||
Command string `json:"command"` // 执行的命令
|
||||
ArgList []string `json:"arg_list"` // 参数列表
|
||||
Err error `json:"-"` // 失败信息
|
||||
}
|
||||
@@ -1,34 +1,31 @@
|
||||
module git.zhangdeman.cn/zhangdeman/redis
|
||||
|
||||
go 1.24.0
|
||||
|
||||
toolchain go1.24.2
|
||||
go 1.22.4
|
||||
|
||||
require (
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260413082525-fb90982b1256
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a
|
||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20260321023345-6c6e467e3a14
|
||||
github.com/go-redis/redismock/v9 v9.2.0
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e
|
||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20240924063449-ef80c6cb79d1
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/redis/go-redis/v9 v9.18.0
|
||||
go.uber.org/zap v1.27.1
|
||||
github.com/redis/go-redis/v9 v9.6.1
|
||||
go.uber.org/zap v1.27.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20251013024601-da007da2fb42 // indirect
|
||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20260112135254-c9ba29f9f674 // indirect
|
||||
github.com/BurntSushi/toml v1.6.0 // indirect
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20241008084126-0b1c661317ee // indirect
|
||||
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211 // indirect
|
||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0 // indirect
|
||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240618035451-8d48a6bd39dd // indirect
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/go-ini/ini v1.67.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mozillazg/go-pinyin v0.21.0 // indirect
|
||||
github.com/sbabiv/xml2map v1.2.1 // indirect
|
||||
github.com/mozillazg/go-pinyin v0.20.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.2.0 // indirect
|
||||
github.com/tidwall/match v1.1.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
|
||||
gopkg.in/ini.v1 v1.67.1 // indirect
|
||||
)
|
||||
@@ -1,105 +1,73 @@
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260127050054-349cdcde813a h1:4apFwfRDdGBkSybcLWzjIYjz8i6yR28Wyt7iBK3K+Po=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260127050054-349cdcde813a/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-20260413082525-fb90982b1256/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=
|
||||
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/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-20260321023345-6c6e467e3a14/go.mod h1:oSmLgHs4EausBSmH4GdpGUtjubPek8hLXTAUc4cPCb0=
|
||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240612081722-31c64d4d4ce7 h1:QR8vMXOTy0NFKdodsGKA4gTNHJMfob3yRFYMXrZj7ek=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240612081722-31c64d4d4ce7/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240924065029-c865046cd9e7 h1:tyCPCMK+68PZ0axZylQHitMVp1d5mzNr9/YqMHXqo+A=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240924065029-c865046cd9e7/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20241008084126-0b1c661317ee h1:4nuaCr5GQcx4z9/xWeEnjmLVV6J0j+QT68+AUKI9dFc=
|
||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20241008084126-0b1c661317ee/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211 h1:I/wOsRpCSRkU9vo1u703slQsmK0wnNeZzsWQOGtIAG0=
|
||||
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211/go.mod h1:SrtvrQRdzt+8KfYzvosH++gWxo2ShPTzR1m3VQ6uX7U=
|
||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0 h1:gUDlQMuJ4xNfP2Abl1Msmpa3fASLWYkNlqDFF/6GN0Y=
|
||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0/go.mod h1:VHb9qmhaPDAQDcS6vUiDCamYjZ4R5lD1XtVsh55KsMI=
|
||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687 h1:uQcGqdzi4UdpZlp4f4FUPeBqoygP58pEKJkmN3ROsE0=
|
||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687/go.mod h1:gf7SW2TXATgux8pfdFedMkXWv2515OtIIM/5c4atkFw=
|
||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240618035451-8d48a6bd39dd h1:2Y37waOVCmVvx0Rp8VGEptE2/2JVMImtxB4dKKDk/3w=
|
||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240618035451-8d48a6bd39dd/go.mod h1:6+7whkCmb4sJDIfH3HxNuXRveaM0gCCNWd2uXZqNtIE=
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e h1:Q973S6CcWr1ICZhFI1STFOJ+KUImCl2BaIXm6YppBqI=
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e/go.mod h1:VpPjBlwz8U+OxZuxzHQBv1aEEZ3pStH6bZvT21ADEbI=
|
||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20240612083858-8d056baada2e h1:+PeWa2QdYBWnL32CfAAgy0dlaRCVNmYZDH4q+9w7Gfg=
|
||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20240612083858-8d056baada2e/go.mod h1:US/pcq2vstE3iyxIHf53w8IeXKkZys7bj/ozLWkRYeE=
|
||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20240924063449-ef80c6cb79d1 h1:LYw8NJeWcOiyrGjH9weyxnaMit94MlIngL+uskbLjtw=
|
||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20240924063449-ef80c6cb79d1/go.mod h1:+2qNxuRsfyfOvXk9HNwn+CmyPmmhhrQm/eIi1FDU1jw=
|
||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/go-redis/redismock/v9 v9.2.0 h1:ZrMYQeKPECZPjOj5u9eyOjg8Nnb0BS9lkVIZ6IpsKLw=
|
||||
github.com/go-redis/redismock/v9 v9.2.0/go.mod h1:18KHfGDK4Y6c2R0H38EUGWAdc7ZQS9gfYxc94k7rWT0=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
||||
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/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/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
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/mozillazg/go-pinyin v0.21.0 h1:Wo8/NT45z7P3er/9YSLHA3/kjZzbLz5hR7i+jGeIGao=
|
||||
github.com/mozillazg/go-pinyin v0.21.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
|
||||
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
||||
github.com/mozillazg/go-pinyin v0.20.0 h1:BtR3DsxpApHfKReaPO1fCqF4pThRwH9uwvXzm+GnMFQ=
|
||||
github.com/mozillazg/go-pinyin v0.20.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
|
||||
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
|
||||
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/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
|
||||
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
|
||||
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
|
||||
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
|
||||
github.com/redis/go-redis/v9 v9.5.3 h1:fOAp1/uJG+ZtcITgZOfYFmTKPE7n4Vclj1wZFgRciUU=
|
||||
github.com/redis/go-redis/v9 v9.5.3/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
||||
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
|
||||
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
|
||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg=
|
||||
github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM=
|
||||
github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
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/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/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
|
||||
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
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/ini.v1 v1.67.1 h1:tVBILHy0R6e4wkYOn3XmiITt/hEVH4TFMYvAX2Ytz6k=
|
||||
gopkg.in/ini.v1 v1.67.1/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
+62
-72
@@ -9,11 +9,9 @@ package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.zhangdeman.cn/zhangdeman/redis/define"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"git.zhangdeman.cn/zhangdeman/redis/define"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -21,124 +19,116 @@ var (
|
||||
)
|
||||
|
||||
// wrapper 常用命令的包装
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:16 2024/6/19
|
||||
type wrapper struct {
|
||||
}
|
||||
|
||||
// Exist 缓存Key是否存在
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:31 2024/6/21
|
||||
func (w *wrapper) Exist(ctx context.Context, instanceFlag string, key string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandExists, key)
|
||||
}
|
||||
|
||||
// TTL ...
|
||||
func (w *wrapper) TTL(ctx context.Context, instanceFlag string, key string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandTTL, key)
|
||||
return Client.Exec(ctx, instanceFlag, "EXISTS", key)
|
||||
}
|
||||
|
||||
// Get Get命令
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:17 2024/6/19
|
||||
func (w *wrapper) Get(ctx context.Context, instanceFlag string, key string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandGet, key)
|
||||
return Client.Exec(ctx, instanceFlag, "GET", key)
|
||||
}
|
||||
|
||||
// Del 删除命令
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:19 2024/6/19
|
||||
func (w *wrapper) Del(ctx context.Context, instanceFlag string, keyList ...string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandDel, strings.Join(keyList, " "))
|
||||
return Client.Exec(ctx, instanceFlag, "DEL", strings.Join(keyList, " "))
|
||||
}
|
||||
|
||||
// SetEx 设置数据并且带有效期, 有效期单位 : s
|
||||
func (w *wrapper) SetEx(ctx context.Context, instanceFlag string, key string, value any, ttl int64, withLock bool) *define.RedisResult {
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:22 2024/6/19
|
||||
func (w *wrapper) SetEx(ctx context.Context, instanceFlag string, key string, value string, ttl int64, withLock bool) *define.RedisResult {
|
||||
now := time.Now().Unix()
|
||||
if ttl > now {
|
||||
// 传入过期时间大于当前时间, 说明是指定具体时间过期, 做一下处理
|
||||
ttl = ttl - now
|
||||
}
|
||||
if withLock {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandSet, key, value, "EX", ttl, "NX")
|
||||
return Client.Exec(ctx, instanceFlag, "SET", key, value, "EX", ttl, "NX")
|
||||
}
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandSet, key, value, "EX", ttl)
|
||||
return Client.Exec(ctx, instanceFlag, "SET", key, value, "EX", ttl)
|
||||
}
|
||||
|
||||
// LPop ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:29 2024/6/19
|
||||
func (w *wrapper) LPop(ctx context.Context, instanceFlag string, key string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandLpop, key)
|
||||
return Client.Exec(ctx, instanceFlag, "LPOP", key)
|
||||
}
|
||||
|
||||
// RPop ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:30 2024/6/19
|
||||
func (w *wrapper) RPop(ctx context.Context, instanceFlag string, key string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandRpop, key)
|
||||
return Client.Exec(ctx, instanceFlag, "RPOP", key)
|
||||
}
|
||||
|
||||
// LPush ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:31 2024/6/19
|
||||
func (w *wrapper) LPush(ctx context.Context, instanceFlag string, key string, value string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandLpush, key, value)
|
||||
return Client.Exec(ctx, instanceFlag, "LPUSH", key, value)
|
||||
}
|
||||
|
||||
// RPush ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:31 2024/6/19
|
||||
func (w *wrapper) RPush(ctx context.Context, instanceFlag string, key string, value string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandRpush, key, value)
|
||||
return Client.Exec(ctx, instanceFlag, "RPUSH", key, value)
|
||||
}
|
||||
|
||||
// HGet ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:33 2024/6/19
|
||||
func (w *wrapper) HGet(ctx context.Context, instanceFlag string, key string, field string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandHget, key, field)
|
||||
return Client.Exec(ctx, instanceFlag, "HGET", key, field)
|
||||
}
|
||||
|
||||
// HSet ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:33 2024/6/19
|
||||
func (w *wrapper) HSet(ctx context.Context, instanceFlag string, key string, field string, value string) *define.RedisResult {
|
||||
return Client.Exec(ctx, instanceFlag, consts.RedisCommandHset, key, field, value)
|
||||
return Client.Exec(ctx, instanceFlag, "HSET", key, field, value)
|
||||
}
|
||||
|
||||
// HDel ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:37 2024/6/19
|
||||
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...)
|
||||
}
|
||||
|
||||
// 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)
|
||||
return Client.Exec(ctx, instanceFlag, "HSET", key, strings.Join(fieldList, " "))
|
||||
}
|
||||