| 123456789101112131415161718192021222324252627282930313233343536 |
- package redis
- import (
- "encoding/json"
- "fmt"
- "github.com/go-redis/redis/v8"
- "github.com/sirupsen/logrus"
- "sportfitness/base/assembly/heartRate/model"
- )
- const hrStoreR4Key = prefix + ":hr_store_r4"
- func HrStoreR4(list []model.HrCourseDetail) {
- cmds, err := getClient().TxPipelined(ctx, func(pipeliner redis.Pipeliner) error {
- for _, one := range list {
- data, err2 := json.Marshal(one.HrResult)
- if err2 != nil {
- panic(err2)
- }
- pipeliner.Set(ctx, fmt.Sprintf("%s:%d", hrStoreR4Key, one.HcId), data, 0)
- }
- return nil
- })
- if err != nil {
- logrus.Errorf("HrStoreR4 保存失败:%s", err)
- return
- }
- for _, r := range cmds {
- if r.Err() != nil {
- logrus.Errorf("HrStoreR4 保存失败:%s", r.Err())
- }
- }
- }
|