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

Commit

Permalink
Don't store the red variable in redis:connect
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
kikito committed May 27, 2015
1 parent a4a5cbd commit 270d38e
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions lua/concurredis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,11 @@ end

concurredis.execute = function(f)

local first_connection = false
if not ngx.ctx.red then
ngx.ctx.red = concurredis.connect()
first_connection = true
end

local red = ngx.ctx.red
local red = concurredis.connect()

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

if first_connection then
red:set_keepalive(KEEPALIVE_TIMEOUT, POOL_SIZE)
ngx.ctx.red = nil
end
red:set_keepalive(KEEPALIVE_TIMEOUT, POOL_SIZE)

local ok, err = result[1], result[2]
if ok then
Expand Down

1 comment on commit 270d38e

@mikz
Copy link
Contributor

@mikz mikz commented on 270d38e Oct 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was there to allow following use the same connection:

concurredis.execute(function(r) 
  concurredis.execute(function(r) ... end)
end)

Please sign in to comment.