Hi,
再次感谢 agentzh !是我的粗心大意导致的。下回,我会更仔细些。
另,openresty是否有提供语法检查功能?
在 2012年10月16日星期二UTC+8下午5时22分20秒,xocecd写道:
我用resty-redis写了一个连接redis的测试程序,发现connect后,连接就中断了,导致后续set,get操作无法进行。
nginx.conf:
location /get {
default_type text/html;
set $ip $arg_ip;
set $key $arg_key;
content_by_lua '
local redis = require "resty.redis";
local res = redis:new();
local ok = res:set_timeout(5000);
ngx.say(ok);
local ok,err = res:connect(ngx.var.ip,6379);
if not ok then
ngx.say("failed to connect",err);
return;
end
res:set_keepalive(0, 100);
local ok, err = res.set(ngx.var.key,"hello");
if not ok then
ngx.say(err);
return;
end
local num ,err = res.get(ngx.var.key);
if not num then
ngx.say(err);
return;
end
if num == ngx.null then
ngx.say("null");
else
ngx.say(num);
end
res:close();
';
}
调用curl "http://127.0.0.1/get?key=test&ip=127.0.0.1",返回not initialized
redis.log显示为:
[27977] 16 Oct 16:17:14 - Accepted 127.0.0.1:33496
[27977] 16 Oct 16:17:14 - Client closed connection
安装配置信息如下:
configure arguments: --prefix=/home/stat3/app/cgi-nginx --add-module=/home/zhihui/agentzh-redis2-nginx-module-1e14554/ --add-module=/home/zhihui/chaoslawful-lua-nginx-module-b5531ff --add-module=/home/zhihui/simpl-ngx_devel_kit-4192ba6 --with-http_ssl_module --add-module=/home/zhihui/agentzh-set-misc-nginx-module-54e2261