41 lines
655 B
Go
41 lines
655 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 := Instance().Set(context.Background(), "name", "qwe123", time.Minute).Result()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(set)
|
|
|
|
get, err := Instance().Get(context.Background(), "name").Result()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
|
|
fmt.Println(get)
|
|
}
|