这是我的代码
func BenchmarkParallelGetSet(b *B) {
parallel := runtime.GOMAXPROCS(0) * 8
b.Run("redigo", func(b *B) {
do(b, func() {
conn := red.Get()
//defer conn.Close()
v, err := conn.Do("SET", "foo", "bar")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(v)
v, err = redis.String(conn.Do("GET", "foo"))
if err != nil {
fmt.Println(err)
return
}
fmt.Println(v)
})
})
}
func newPool(MaxIdle int) *redis.Pool {
return &redis.Pool{
MaxIdle: MaxIdle,
IdleTimeout: 240 * time.Second,
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", "127.0.0.1:6379")
if err != nil {
return nil, err
}
return c, err;
},
TestOnBorrow: func(c redis.Conn, t time.Time) error {
if time.Since(t) < time.Minute {
return nil
}
_, err := c.Do("PING")
return err
},
}
}
错误是
--- FAIL: BenchmarkParallelGetSet/redigo-8
bench_test.go:192: read tcp 127.0.0.1:51701->127.0.0.1:6379: read: connection reset by peer
这是怎么了? 需要任何帮助,谢谢。