Hello!
2013/4/9 li.huang:
>
> 请教怎么让连续多条srcache store指令?
>
你想在一个 location 内部指定多条 srcache_store 指令?这是不行的,你这么做会得到类似下面这条错误消息:
nginx: [emerg] "srcache_store" directive is duplicate in conf/nginx.conf:47
如果你想让把响应存储到多个目标,你可以使用 ngx_lua 模块来服务 srcache_store 对应的子请求,并在 Lua 里自己把数据推送到多个目标。即:
location / {
...
srcache_store PUT /sub $key;
}
location = /sub {
internal;
content_by_lua '
local key = ngx.unescape_uri(ngx.var.arg_key)
local data = ngx.req.get_body_data()
if not data then
ngx.log(ngx.ERR, "no request body data found")
return ngx.exit(500)
end
-- push the data and key to memcached, redis, and/or mysql
-- via lua-resty-memcached, lua-resty-redis, and/or lua-resty-mysql,
-- respecitively
';
}
Best regards,
-agentzh