您的位置:首页 > 运维架构

openresty学习

2016-07-15 10:21 253 查看
1.引用lua脚本文件

content_by_lua_file lua/hello.lua;

lua的文件夹位置,应该放在nginx的安装目录下如: openresty安装在opt目录下,则lua的文件夹位置: /opt/openresty/nginx/lua

nginx可执行文件的位置:/opt/openresty/nginx/sbin

2.lua

/opt/openresty/lualib/resty

3.lua_shared_dict 缓存 

每个work共享,需要加锁

nginx.conf中添加 lua_shared_dict  mycache 128m

在lua脚本中添加获取缓存的函数

function getCache(key)

    local cache = ngx.shared.my_cache

    local value = cache:get(key)

    return value

end

4.lrucache

每个work独占,所以要考虑总内存消耗的问题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  openresty nginx