fix(models): handle JSON marshaling errors in SetRedis functions to improve error handling and data integrity

This commit is contained in:
keven1024
2026-04-06 11:26:38 +08:00
parent 17fa39b830
commit 83f6be0486
5 changed files with 20 additions and 5 deletions

View File

@@ -29,7 +29,10 @@ func GetRedisTaskInfo(taskId string) (*map[string]any, error) {
func SetRedisTaskInfo(taskId string, taskInfo map[string]any) error {
rdb, ctx := utils.GetRedisClient()
jsonData, _ := json.Marshal(taskInfo)
jsonData, err := json.Marshal(taskInfo)
if err != nil {
return err
}
return rdb.Do(
ctx,
rdb.B().Set().Key(fmt.Sprintf("015:taskInfoMap:%s", taskId)).Value(string(jsonData)).Ex(time.Hour).Build(),