感谢指点,最终代码通过测试了,http://pastebin.com/5p99cCuj
还有个问题,如果我把 redis 和 redis2 两个模块用 lua-resty-redis 来写和上面的性能相比如何?
你在 http://wiki.nginx.org/HttpRedis2Module#Lua_Interoperability 上这样写:
“This module can be served as a non-blocking redis2 client for
HttpLuaModule (but nowadays it is recommended to use the
lua-resty-redis library instead, which is much simpler to use and more efficient most of the time).”
意思是说 大部分情况 lua-resty-redis 更简单有效,但 redis 和 redis2 模块 是c语言,而
lua-resty-redis 是 lua 语言,应该是 redis 和 redis2 模块更高效的?
On Friday, October 26, 2012 2:21:14 AM UTC+8, agentzh wrote:
Hello!2012/10/25 Bill Zhu:
>
>
> 这里面又用到了很多新学的,很可能有错误,希望能指出。。。
>
由于我没有时间仔细 review 每一位用户提供的 Lua 代码,特别是当对方还没有遇到具体问题的时候。
所以我建议直接在你本地运行和测试你的代码,当有问题时,自己通过加入调试输出语言进行调试。当有困惑时,首先参阅官方文档。当你遇到的行为与文档有出入时,请准备一个能复现问题的最小化的完整示例(最好
20 行代码以内),并贴到这里。
谢谢合作!
Best regards,
-agentzh