mycommon/myredis/redis_test.go

40 lines
560 B
Go
Raw Normal View History

2023-03-20 15:50:45 +08:00
package myredis
2023-01-15 00:21:08 +08:00
import (
"fmt"
"testing"
"time"
)
func TestRedis(t *testing.T) {
redis, err := New(&Config{
Addr: "127.0.0.1:6379",
Password: "",
DB: 15,
PoolSize: 16,
MinIdleConn: 4,
MaxConnAge: "1h",
IdleTimeout: "10m",
})
if err != nil {
fmt.Println(err)
return
}
defer redis.Close()
set, err := redis.Set("name", "qwe123", time.Minute)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(set)
get, err := redis.Get("name")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(get)
}