完善redis示例

This commit is contained in:
John 2018-04-21 10:50:04 +08:00
parent 16e2fd0680
commit 7043b3ebb2
2 changed files with 23 additions and 4 deletions

View File

@ -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))
}

View 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))
}