修复构建redis结果读取的异常 + 增加exist方法

This commit is contained in:
白茶清欢 2024-06-21 12:43:26 +08:00
parent 27e193a0ea
commit 9daae92046
2 changed files with 18 additions and 8 deletions

View File

@ -74,13 +74,14 @@ func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command strin
cmdParamList = append(cmdParamList, itemArg)
}
res := &define.RedisResult{
StartTime: time.Now().UnixMilli(),
FinishTime: 0,
UsedTime: 0,
Result: "",
Command: command,
ArgList: argStrList,
Err: nil,
StartTime: time.Now().UnixMilli(),
FinishTime: 0,
UsedTime: 0,
Result: "",
Command: command,
ArgList: argStrList,
Err: nil,
InstanceFlag: instanceFlag,
}
defer func() {
res.FinishTime = time.Now().UnixMilli()
@ -110,7 +111,7 @@ func (o *OwnClient) Exec(ctx context.Context, instanceFlag string, command strin
if res.Err = cmdRes.Err(); nil != res.Err {
return res
}
res.Result = cmdRes.String()
res.Result = wrapperOperate.AnyDataType(cmdRes.Val()).ToString().Value()
return res
}

View File

@ -26,6 +26,15 @@ var (
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, "EXISTS", key)
}
// Get Get命令
//
// Author : go_developer@163.com<白茶清欢>