mirror of
https://gitee.com/johng/gf
synced 2026-07-07 06:15:15 +08:00
示例代码更新
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"gitee.com/johng/gf/g/database/gdb"
|
"gitee.com/johng/gf/g/database/gdb"
|
||||||
|
"gitee.com/johng/gf/g/util/gutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -26,7 +26,7 @@ func main() {
|
|||||||
// 执行2次查询并将查询结果缓存3秒,并可执行缓存名称(可选)
|
// 执行2次查询并将查询结果缓存3秒,并可执行缓存名称(可选)
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
r, _ := db.Table("user").Cache(3, "vip-user").Where("uid=?", 1).One()
|
r, _ := db.Table("user").Cache(3, "vip-user").Where("uid=?", 1).One()
|
||||||
fmt.Println(r.ToMap())
|
gutil.Dump(r.ToMap())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行更新操作,并清理指定名称的查询缓存
|
// 执行更新操作,并清理指定名称的查询缓存
|
||||||
@ -34,14 +34,5 @@ func main() {
|
|||||||
|
|
||||||
// 再次执行查询,启用查询缓存特性
|
// 再次执行查询,启用查询缓存特性
|
||||||
r, _ := db.Table("user").Cache(3, "vip-user").Where("uid=?", 1).One()
|
r, _ := db.Table("user").Cache(3, "vip-user").Where("uid=?", 1).One()
|
||||||
fmt.Println(r.ToMap())
|
gutil.Dump(r.ToMap())
|
||||||
|
|
||||||
for k, v := range db.GetQueriedSqls() {
|
|
||||||
fmt.Println(k, ":")
|
|
||||||
fmt.Println("Sql :", v.Sql)
|
|
||||||
fmt.Println("Args :", v.Args)
|
|
||||||
fmt.Println("Error:", v.Error)
|
|
||||||
fmt.Println("Cost :", v.Cost)
|
|
||||||
fmt.Println("Func :", v.Func)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -11,7 +11,7 @@ func main() {
|
|||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: "3306",
|
Port: "3306",
|
||||||
User: "root",
|
User: "root",
|
||||||
Pass: "8692651",
|
Pass: "123456",
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Type: "mysql",
|
Type: "mysql",
|
||||||
Role: "master",
|
Role: "master",
|
||||||
|
|||||||
Reference in New Issue
Block a user