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