f
This commit is contained in:
@@ -39,6 +39,7 @@ type ServiceContext struct {
|
||||
OrderModel model.OrderModel
|
||||
OrderRefundModel model.OrderRefundModel
|
||||
QueryModel model.QueryModel
|
||||
QueryUserRecordModel model.QueryUserRecordModel
|
||||
QueryCleanupLogModel model.QueryCleanupLogModel
|
||||
QueryCleanupDetailModel model.QueryCleanupDetailModel
|
||||
QueryCleanupConfigModel model.QueryCleanupConfigModel
|
||||
@@ -108,10 +109,12 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
cacheConf := c.CacheRedis
|
||||
|
||||
// 初始化Redis客户端
|
||||
// 设置超时时间为30秒,解决连接超时问题
|
||||
redisConf := redis.RedisConf{
|
||||
Host: cacheConf[0].Host,
|
||||
Pass: cacheConf[0].Pass,
|
||||
Type: cacheConf[0].Type,
|
||||
Host: cacheConf[0].Host,
|
||||
Pass: cacheConf[0].Pass,
|
||||
Type: cacheConf[0].Type,
|
||||
PingTimeout: 30 * time.Second, // 设置30秒超时,解决 "context deadline exceeded" 错误
|
||||
}
|
||||
redisClient := redis.MustNewRedis(redisConf)
|
||||
|
||||
@@ -128,6 +131,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
// ============================== 订单相关模型 ==============================
|
||||
orderModel := model.NewOrderModel(db, cacheConf)
|
||||
queryModel := model.NewQueryModel(db, cacheConf)
|
||||
queryUserRecordModel := model.NewQueryUserRecordModel(db, cacheConf)
|
||||
orderRefundModel := model.NewOrderRefundModel(db, cacheConf)
|
||||
queryCleanupLogModel := model.NewQueryCleanupLogModel(db, cacheConf)
|
||||
queryCleanupDetailModel := model.NewQueryCleanupDetailModel(db, cacheConf)
|
||||
@@ -238,6 +242,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
// 订单相关模型
|
||||
OrderModel: orderModel,
|
||||
QueryModel: queryModel,
|
||||
QueryUserRecordModel: queryUserRecordModel,
|
||||
OrderRefundModel: orderRefundModel,
|
||||
QueryCleanupLogModel: queryCleanupLogModel,
|
||||
QueryCleanupDetailModel: queryCleanupDetailModel,
|
||||
|
||||
Reference in New Issue
Block a user