Hello!
On Thu, Nov 15, 2012 at 5:33 AM, actioncao2012 wrote:
>
> 两篇文章都看过,只是我不想用别的模块,就想用openresty里集成的模块(用着放心),王老师(huoding)的教程看了,没有涉及到创建连接和向客户端写数据,刚接触,见谅!
我不清楚你这里说的“创建连接”具体是什么意思,毕竟连接分“下游连接”和“上游连接”两种。由你的用户,即 HTTP 客户端发起指向 nginx
的连接是“下游连接”,由 nginx 发起的,指向后端的 redis 或者 mysql 等服务的则是“上游连接”。
如果是“下游连接”,连接的创建自然是你的用户发起,与 openresty 无关,如果是“上游连接”的创建,则取决于你使用的后端服务。如果是
redis,则可参见 lua-resty-redis 库的文档,里面也有代码示例:
https://github.com/agentzh/lua-resty-redis
向客户端写数据,使用 ngx_lua 的 ngx.print() 函数即可:
http://wiki.nginx.org/HttpLuaModule#ngx.print
Best regards,
-agentzh
--
邮件自: 列表“openresty”,专用于技术讨论!
发言: 请发邮件到 openresty@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@googlegroups.com
详情: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
建议: 提问的智慧 http://wiki.woodpecker.org.cn/moin/AskForHelp
教程: http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html