Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Commit 270d38e

Browse files
committed
Don't store the red variable in redis:connect
Apparently, doing so can result in errors like the ones I am seeing in the logs. More info here: openresty/lua-resty-redis#28 (see answer about connect)
1 parent a4a5cbd commit 270d38e

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

lua/concurredis.lua

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,11 @@ end
176176

177177
concurredis.execute = function(f)
178178

179-
local first_connection = false
180-
if not ngx.ctx.red then
181-
ngx.ctx.red = concurredis.connect()
182-
first_connection = true
183-
end
184-
185-
local red = ngx.ctx.red
179+
local red = concurredis.connect()
186180

187181
local result = { error_handler.execute(function() return f(red) end) }
188182

189-
if first_connection then
190-
red:set_keepalive(KEEPALIVE_TIMEOUT, POOL_SIZE)
191-
ngx.ctx.red = nil
192-
end
183+
red:set_keepalive(KEEPALIVE_TIMEOUT, POOL_SIZE)
193184

194185
local ok, err = result[1], result[2]
195186
if ok then

0 commit comments

Comments
 (0)