From dda20339afc91b2424da37ec423db38c0f1c2972 Mon Sep 17 00:00:00 2001 From: wubin48435 Date: Tue, 2 Jul 2024 13:01:29 +0800 Subject: [PATCH] add ManualConfigure parameter to cache config --- framework/config/config.go | 3 ++- framework/database/database.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/config/config.go b/framework/config/config.go index bbf3d7f4..2d13ef71 100644 --- a/framework/config/config.go +++ b/framework/config/config.go @@ -501,7 +501,8 @@ type Config struct { ConnMaxIdleTime string } Cache struct { - Enable bool + Enable bool + ManualConfigure bool } Prometheus struct { Enable bool diff --git a/framework/database/database.go b/framework/database/database.go index 7aa19003..39ba66cf 100644 --- a/framework/database/database.go +++ b/framework/database/database.go @@ -288,7 +288,7 @@ func NewDb(conf config.Config) (db *gorm.DB) { ConfigureMetrics(db, conf.Db.Prometheus.DBName, uint32(conf.Db.Prometheus.RefreshInterval), nil, collectors...) } - if conf.Db.Cache.Enable && stringutils.IsNotEmpty(conf.Cache.Stores) { + if conf.Db.Cache.Enable && stringutils.IsNotEmpty(conf.Cache.Stores) && !conf.Db.Cache.ManualConfigure { ConfigureDBCache(db, cache.NewCacheManager(conf)) } return