mirror of
https://gitee.com/johng/gf
synced 2026-07-06 21:45:34 +08:00
example updates for package gcache
This commit is contained in:
29
.example/os/gcache/note_interface_value.go
Normal file
29
.example/os/gcache/note_interface_value.go
Normal file
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/os/gcache"
|
||||
"github.com/gogf/gf/os/gctx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
type User struct {
|
||||
Id int
|
||||
Name string
|
||||
Site string
|
||||
}
|
||||
var (
|
||||
ctx = gctx.New()
|
||||
user *User
|
||||
key = `UserKey`
|
||||
value = &User{
|
||||
Id: 1,
|
||||
Name: "GoFrame",
|
||||
Site: "https://goframe.org",
|
||||
}
|
||||
)
|
||||
_ = gcache.Ctx(ctx).Set(key, value, 0)
|
||||
v, _ := gcache.Ctx(ctx).GetVar(key)
|
||||
_ = v.Scan(&user)
|
||||
fmt.Printf(`%#v`, user)
|
||||
}
|
||||
Reference in New Issue
Block a user