This commit is contained in:
hoteas
2018-04-08 16:02:13 +00:00
parent 36dec599a2
commit 546058513f
4 changed files with 187 additions and 78 deletions
+7 -8
View File
@@ -5,8 +5,9 @@ import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"go.hoteas.com/hotime"
"go.hoteas.com/hotime/cache"
//"go.hoteas.com/hotime/cache"
"golang.org/x/net/websocket"
"time"
)
func main() {
@@ -32,14 +33,8 @@ 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:=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"
@@ -81,7 +76,11 @@ func main() {
for true {
msg := make([]byte, 5120)
n, err := ws.Read(msg)
go func() {
time.Sleep(time.Second*5)
ws.Write([]byte("dsadasdasgregergrerge"))
}()
if err != nil {
return
}