标签:
ngx_lua将lua嵌nginx,让nginx运行lua脚本。高并发,非堵塞过程中的各种请求。
url要求nginxserver,然后lua查询redis,返回json数据。
參见《LNMLGC》架构
二.安装redis2-nginx-module模块
get https://github.com/openresty/echo-nginx-module...
http {
...
upstream redis_pool {
server localhost:6379;
keepalive 1024 single;
//定义连接池大小,当连接数达到此数后。兴许的连接为短连接
}
server {
...
location /get_redis{
#internal;
set_unescape_uri $key $arg_key;
redis2_query hgetall $key;
redis2_pass redis_pool;
}
location /json {
content_by_lua_file conf/test.lua;
}
}
}local json = require("json")
local parser = require("redis.parser")
local res = ngx.location.capture("/get_redis",{
args = { key = ngx.var.arg_key }
})
if res.status == 200 then
reply = parser.parse_reply(res.body)
value = json.encode(reply)
ngx.say(value)
a = json.decode(value)
ngx.say(a[2])
endkey=ttlsa
["www","www.ttlsa.com","mail","mail.ttlsa.com"]
www.ttlsa.com
标签:
原文地址:http://www.cnblogs.com/mengfanrong/p/4561593.html