add cache to framework
This commit is contained in:
+8
-7
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user