openresty / lua-resty-mysql

Nonblocking Lua MySQL driver library for ngx_lua or OpenResty
708 stars 236 forks source link

Have some questions in db:connect #30

Open gaoyue1989 opened 9 years ago

gaoyue1989 commented 9 years ago

Like an example,is each http request creates a new connection, or to check is have a pool. If have a pool,use it .if not create a pool

local ok, err, errno, sqlstate = db:connect{
                    host = "127.0.0.1",
                    port = 3306,
                    database = "ngx_test",
                    user = "ngx_test",
                    password = "ngx_test",
                    max_packet_size = 1024 * 1024 }  
agentzh commented 9 years ago

@gaoyue1989 To quote the official documentation for the connect method:

Before actually resolving the host name and connecting to the remote backend, this method will always look up the connection pool for matched idle connections created by previous calls of this method.

See https://github.com/openresty/lua-resty-mysql#connect

BTW, general questions should go to the openresty-en mailing list instead. Please see https://openresty.org/#Community Thanks for your cooperation!