mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 20:58:47 +08:00
完善redis示例
This commit is contained in:
parent
16e2fd0680
commit
7043b3ebb2
@ -2,14 +2,17 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitee.com/johng/gf/g/util/gconv"
|
||||
"gitee.com/johng/gf/g/database/gredis"
|
||||
)
|
||||
|
||||
func main() {
|
||||
redis := gredis.New("127.0.0.1:6379", 1)
|
||||
fmt.Println(redis.Do("SET", "k1", "v1"))
|
||||
fmt.Println(redis.Do("SET", "k2", "v3"))
|
||||
fmt.Println(redis.Do("GET", "k2"))
|
||||
fmt.Println(redis.Stats())
|
||||
redis.Do("SET", "k1", "v1")
|
||||
redis.Do("SET", "k2", "v2")
|
||||
v1, _ := redis.Do("GET", "k1")
|
||||
v2, _ := redis.Do("GET", "k1")
|
||||
fmt.Println(gconv.String(v1))
|
||||
fmt.Println(gconv.String(v2))
|
||||
}
|
||||
|
||||
|
16
geg/database/redis/gredis_gins.go
Normal file
16
geg/database/redis/gredis_gins.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitee.com/johng/gf/g/frame/gins"
|
||||
"gitee.com/johng/gf/g/util/gconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/gitee.com/johng/gf/geg/frame")
|
||||
redis := gins.Redis("cache")
|
||||
redis.Do("SET", "k", "v")
|
||||
v, _ := redis.Do("GET", "k")
|
||||
fmt.Println(gconv.String(v))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user