mycommon/myredis/redis_test.go

41 lines
643 B
Go

package myredis
import (
"context"
"fmt"
"testing"
"time"
)
func TestRedis(t *testing.T) {
err := InitDefault(&Config{
Addr: "192.168.244.128:6379",
Password: "",
DB: 15,
PoolSize: 16,
MinIdleConn: 4,
MaxConnAge: "1h",
IdleTimeout: "10m",
})
if err != nil {
fmt.Println(err)
return
}
defer CloseAllInstance()
set, err := DB().Set(context.Background(), "name", "qwe123", time.Minute).Result()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(set)
get, err := DB().Get(context.Background(), "name").Result()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(get)
}