```
feat(database): 自动迁移表结构并优化数据库初始化函数 将 `AutoMigrate` 逻辑从各数据库初始化方法中提取至统一的 `NewDatabase` 方法内, 避免重复代码。同时修改 `Databases`、`Etcd`、`Memory` 和 `RedisCache` 函数签名, 使其返回实例而非通过参数传递,提高代码可读性和一致性。 ```
This commit is contained in:
@@ -6,11 +6,13 @@ import (
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
)
|
||||
|
||||
func RedisCache(cfg string, cli *redis.RedisClient) {
|
||||
func RedisCache(cfg string) (cli *redis.RedisClient) {
|
||||
if cfg != "" {
|
||||
cli = redis.New(cfg, vars.ServiceKey)
|
||||
|
||||
// print inform.
|
||||
print.Info("[BSM - %s] Cache: %s, DBIndex: %d", vars.ServiceKey, cfg, cli.DB)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user