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
+3 -2
View File
@@ -6,12 +6,13 @@ import (
_ "github.com/mattn/go-sqlite3"
)
func SetDB(appIns *hotime.Application) {
func SetDB(appIns *hotime.Application, config hotime.Map) {
appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB {
db, e := sql.Open("sqlite3", appIns.Config.GetString("dbName"))
db, e := sql.Open("sqlite3", config.GetString("path"))
if e != nil && len(err) != 0 {
err[0].SetError(e)
}
return db
})
appIns.Db.Type = "sqlite"
}