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
+9 -12
View File
@@ -1,6 +1,7 @@
package hotime
import (
"./tools/db"
"bytes"
"database/sql"
"encoding/json"
@@ -158,21 +159,9 @@ func (this *Application) Run(router Router) {
//启动实例
func (this *Application) SetConnectDB(connect func(err ...*Error) *sql.DB) {
//this.Db.DBCached=false
//if this.Config.GetCeilInt("dbCached")!=0{
// this.Db.DBCached=true
//}
this.connectDbFunc = connect
this.Db.SetConnect(this.connectDbFunc)
this.Db.DBCached = false
if this.Config.GetCeilInt("dbCached") != 0 {
this.Db.DBCached = true
}
this.Db.Type = this.Config.GetString("dbType")
}
//设置配置文件路径全路径或者相对路径
@@ -458,3 +447,11 @@ func (this *Application) crossDomain(context *Context) {
header.Set("Access-Control-Allow-Origin", refer)
}
}
func Init(config string) Application {
appIns := Application{}
//手动模式,
appIns.SetConfig(config)
db.SetDB(&appIns)
//appIns.SetCache()
return appIns
}