add cache to framework

This commit is contained in:
hoteas
2021-05-24 05:47:56 +08:00
parent 253f836571
commit c8e926446e
9 changed files with 97 additions and 29 deletions
+8 -7
View File
@@ -4,15 +4,16 @@ import (
"../../../hotime"
"../mysql"
"../sqlite"
"strings"
)
func SetDB(appIns *hotime.Application) {
if appIns.Config.GetString("dbType") == "sqlite" || strings.Index(appIns.Config.GetString("dbName"), ".db") == len(appIns.Config.GetString("dbName"))-3 {
appIns.Config["dbType"] = "sqlite"
sqlite.SetDB(appIns)
} else {
appIns.Config["dbType"] = "mysql"
mysql.SetDB(appIns)
db := appIns.Config.GetMap("db")
dbSqlite := db.GetMap("sqlite")
dbMysql := db.GetMap("mysql")
if db != nil && dbSqlite != nil {
sqlite.SetDB(appIns, dbSqlite)
}
if db != nil && dbMysql != nil {
mysql.SetDB(appIns, dbMysql)
}
}