forked from mirror/ledisdb
go client add conn buffer size config
This commit is contained in:
parent
37453395b2
commit
8889197a39
|
@ -12,8 +12,10 @@ const (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
Addr string
|
||||
MaxIdleConns int
|
||||
Addr string
|
||||
MaxIdleConns int
|
||||
ReadBufferSize int
|
||||
WriteBufferSize int
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
|
@ -36,6 +38,12 @@ func NewClient(cfg *Config) *Client {
|
|||
c := new(Client)
|
||||
|
||||
c.cfg = cfg
|
||||
if c.cfg.ReadBufferSize == 0 {
|
||||
c.cfg.ReadBufferSize = 4096
|
||||
}
|
||||
if c.cfg.WriteBufferSize == 0 {
|
||||
c.cfg.WriteBufferSize = 4096
|
||||
}
|
||||
|
||||
c.conns = list.New()
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@ func (c *Conn) readReply() (interface{}, error) {
|
|||
}
|
||||
|
||||
func (c *Client) newConn(addr string) *Conn {
|
||||
co := NewConn(addr)
|
||||
co := NewConnSize(addr, c.cfg.ReadBufferSize, c.cfg.WriteBufferSize)
|
||||
co.client = c
|
||||
|
||||
return co
|
||||
|
|
|
@ -268,6 +268,8 @@ func main() {
|
|||
cfg := new(ledis.Config)
|
||||
cfg.Addr = addr
|
||||
cfg.MaxIdleConns = *clients
|
||||
cfg.ReadBufferSize = 10240
|
||||
cfg.WriteBufferSize = 10240
|
||||
client = ledis.NewClient(cfg)
|
||||
|
||||
if *round <= 0 {
|
||||
|
|
Loading…
Reference in New Issue