升级数据库后更新缓存

This commit is contained in:
ryan
2026-06-09 16:47:37 +08:00
parent b1c161b255
commit 055005688a
2 changed files with 71 additions and 0 deletions
+12
View File
@@ -25,6 +25,7 @@ import (
"github.com/Rain-kl/Wavelet/internal/config"
"github.com/Rain-kl/Wavelet/internal/db"
"github.com/Rain-kl/Wavelet/internal/model"
"github.com/pressly/goose/v3"
)
@@ -75,5 +76,16 @@ func Migrate() {
log.Fatalf("[%s] goose migrate failed: %v\n", dbType(), err)
}
clearSystemConfigCache()
log.Printf("[%s] goose migrate success\n", dbType())
}
func clearSystemConfigCache() {
if db.Redis == nil {
return
}
if err := db.Redis.Del(context.Background(), db.PrefixedKey(model.SystemConfigRedisHashKey)).Err(); err != nil {
log.Printf("[%s] clear system config cache failed: %v\n", dbType(), err)
}
}