2017-02-25 125 views
0

連接Tarantool我想創建init_by_lua_blockinit_worker_by_lua_block連接Tarantool數據庫,然後用在每個content_by_lua_block創建連接:Openresty:創建初始化

init_by_lua_block { 
    local tnt = require 'resty.tarantool' 

    local tar, err = tnt:new({ 
     host = '127.0.0.1', 
     port = 3312, 
     user = 'user', 
     password = 'password', 
     socket_timeout = 2000 
    }) 

    local res, err = tar:connect() 
} 

但cosocket API中的指令init_*_by_lua*被禁用。我如何創建連接而不是爲每個請求創建連接?

回答