feat(database): 自动迁移表结构并优化数据库初始化函数

将 `AutoMigrate` 逻辑从各数据库初始化方法中提取至统一的 `NewDatabase` 方法内,
避免重复代码。同时修改 `Databases`、`Etcd`、`Memory` 和 `RedisCache` 函数签名,
使其返回实例而非通过参数传递,提高代码可读性和一致性。
```
This commit is contained in:
2025-09-23 16:17:03 +08:00
parent 518c237061
commit 21716c4340
5 changed files with 17 additions and 20 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/allegro/bigcache/v3"
)
func Memory(cli *bigcache.BigCache, opts *bigcache.Config) {
func Memory(opts *bigcache.Config) (cli *bigcache.BigCache) {
if opts == nil {
opts = &bigcache.Config{
Shards: 1024,
@@ -32,4 +32,5 @@ func Memory(cli *bigcache.BigCache, opts *bigcache.Config) {
}
print.Success("[BSM - %s] Memory Cache: Shards=%d, MaxEntrySize=%d", vars.ServiceKey, opts.Shards, opts.MaxEntrySize)
return
}