This commit is contained in:
hoteas
2018-04-04 18:44:00 +00:00
parent c3d0b64d72
commit 3488eab401
7 changed files with 369 additions and 113 deletions
+3 -3
View File
@@ -6,9 +6,6 @@
"dbPort": "3306",
"dbPwd": "root",
"dbUser": "root",
"redisPort":"6379",
"redisHost":"192.168.6.254",
"redisPwd":"9rusdfjk482fjdfo2e023",
"defFile": [
"index.html",
"index.htm"
@@ -16,6 +13,9 @@
"error": {},
"logLevel": 0,
"port": "80",
"redisHost": "192.168.6.254:6379",
"redisPort": "6379",
"redisPwd": "9rusdfjk482fjdfo2e023",
"sessionName": "HOTIME",
"tpt": "example/tpt"
}
+19 -2
View File
@@ -5,13 +5,20 @@ import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"go.hoteas.com/hotime"
"go.hoteas.com/hotime/cache"
"golang.org/x/net/websocket"
"github.com/garyburd/redigo/redis"
)
func main() {
hotime.CacheRedis{nil,redis.Dial()}
appIns := hotime.Application{}
i := 0
appIns.SetConnectListener(func(context *hotime.Context) bool {
@@ -23,6 +30,16 @@ func main() {
//手动模式,
appIns.SetConfig("example/config/config.json")
ca:=hotime.CacheIns(&cache.CacheRedis{Host:appIns.Config.GetString("redisHost"),Pwd:appIns.Config.GetString("redisPwd"),Time:appIns.Config.GetCeilInt64("cacheLongTime")})
ca.Cache("x",hotime.Map{"1":"2132"})
fmt.Println(ca.Cache("x").ToMap())
fmt.Println(ca.Cache("x",nil).Data)
fmt.Println(ca.Cache("x",nil).Data)
fmt.Println(ca.Cache("x").Data)
fmt.Println(ca.Cache("x").Data)
appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB {
query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
"@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"