- 在查询订单摘要信息时添加了对大量数据的分页处理,提升性能 - 新增 GetOrderCountByMap 函数用于获取订单总数 - 更新 QueryTotalSummary 和 QueryTodaySummary 函数,支持分页查询 - 为相关函数添加了 context 参数,以便于传递请求上下文 - 优化了部分代码结构,提高可读性和可维护性
37 lines
773 B
Go
37 lines
773 B
Go
package redis
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/go-redis/redis/v7"
|
|
)
|
|
|
|
// New 创建redis客户端
|
|
//func New() *redis.Client {
|
|
// if Client != nil {
|
|
// return Client
|
|
// }
|
|
// redisCfg, err := config.GetRedisConfig()
|
|
// if err != nil {
|
|
//
|
|
// }
|
|
//
|
|
// Client = redis.NewClient(&redis.Options{
|
|
// Addr: fmt.Sprintf("%s:%s", redisCfg.Host, redisCfg.Host), // redis地址
|
|
// Password: redisCfg.Password, // 密码
|
|
// DB: redisCfg.DB, // 使用默认数据库
|
|
// })
|
|
// return Client
|
|
//}
|
|
|
|
var Client *redis.Client
|
|
|
|
//func init() {
|
|
// New()
|
|
//}
|
|
|
|
// Set 设置key-value
|
|
func Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd {
|
|
return Client.Set(key, value, expiration)
|
|
}
|