mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
add package gkvdb; add kvdb storage feature for ghttp.Server
This commit is contained in:
18
.example/database/gkvdb/badger/main.go
Normal file
18
.example/database/gkvdb/badger/main.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/dgraph-io/badger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Open the Badger database located in the /tmp/badger directory.
|
||||
// It will be created if it doesn't exist.
|
||||
db, err := badger.Open(badger.DefaultOptions("/tmp/badger"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
// Your code here…
|
||||
}
|
||||
17
.example/database/gkvdb/main1.go
Normal file
17
.example/database/gkvdb/main1.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/database/gkvdb"
|
||||
)
|
||||
|
||||
func main() {
|
||||
key := []byte("key")
|
||||
//value := []byte("value")
|
||||
|
||||
db := gkvdb.Instance()
|
||||
db.SetPath("/tmp/gkvdb/test")
|
||||
//db.Set(key, value)
|
||||
fmt.Println(db.Get(key))
|
||||
}
|
||||
@ -8,7 +8,7 @@ import (
|
||||
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.SetSessionMaxAge(72000000)
|
||||
s.SetSessionMaxAge(60)
|
||||
s.SetSessionIdName("gpadminssid")
|
||||
s.BindHandler("/set", func(r *ghttp.Request) {
|
||||
r.Session.Set("time", gtime.Second())
|
||||
|
||||
Reference in New Issue
Block a user