package main
import (
"context"
"fmt"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/util/gconv"
)
var (
config = gredis.Config{
Address: "192.168.1.2:6379, 192.168.1.3:6379",
Db : 1,
}
ctx = context.Background()
)
func main() {
group := "test"
gredis.SetConfig(&config, group)
redis := gredis.Instance(group)
defer redis.Close(ctx)
_, err := redis.Do(ctx, "SET", "k", "v")
if err != nil {
panic(err)
}
r, err := redis.Do(ctx, "GET", "k")
if err != nil {
panic(err)
}
fmt.Println(gconv.String(r))
}
5 Comments
unite小伟
key的过期时间是在哪里设置?
aries
gleke
D.Rose
你好,我将 redis 闲置的最小连接数设置为 4,为什么这四个闲置连接,永远不会被用到呢?
fd=9 name= age=14 idle=14 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
fd=11 name= age=14 idle=14 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
fd=14 name= age=14 idle=14 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
fd=12 name= age=14 idle=14 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=NULL
fd=10 name= age=14 idle=3 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=get
我执行的命令,都会再重新创建啊一个连接,那 4 个闲置连接,好像用于都不会被使用,是我的配置有问题吗?
edzhao
redis 能否有像mysql 那种debug模式,以及日志