Hello!
On Mon, Feb 3, 2014 at 9:01 AM, pir.tiv wrote:
> Hello. I am not Lua a programmer at all.
>
Lua is a simple language and the following (short) language manual
should be sufficient:
http://www.lua.org/manual/5.1/manual.html
>
> local backendInfo, err = red:hmget(subdomain, 'backend', 'dbserver',
> 'dbpassword', 'staticserver')
> if backendInfo[1] == nil then --problem here
I guess you should use "ngx.null" instead of "nil" here. Because the
redis "nil" value is represented as ngx.null in lua-resty-redis (not
Lua nil!):
https://github.com/agentzh/lua-resty-redis#methods
And you should test if backendInfo is nil for error handling (like
network failure and etc). Basically:
local backendInfo, err = red:hmget(subdomain, 'backend',
'dbserver',
'dbpassword', 'staticserver')
if not backendInfo then
ngx.log(ngx.ERR, "failed to do hmget: ", err)
return
end
if backendInfo[1] == ngx.null then
...
end
Also, please always check out your nginx's error.log file when you
have problems (and always provide error messages and etc (if any) in
your error.log when reporting problems).
BTW, to debug results returned from lua-resty-redis, it is recommended
to use the lua-cjson library to output the contents in the returned
values. See
https://github.com/agentzh/lua-resty-redis#debugging
This should save you (and us) a lot of time ;)
Regards,
-agentzh