Nginx + Lua + 共享内存
2015-03-16 17:43
405 查看
转自:http://blog.csdn.net/lxb_champagne/article/details/17099383
rule.txt文件格式
lua_package_path "/usr/local/share/luajit-2.0.2/jit?.lua;;"; lua_shared_dict devicedb 45m; location /query { default_type 'text/plain'; content_by_lua ' local args = ngx.req.get_uri_args() local devicetype = args["device"] local devicedb = ngx.shared.devicedb local res = devicedb:get(devicetype) ngx.say(res) '; } location /update { default_type 'text/plain'; content_by_lua ' local devicedb = ngx.shared.devicedb for item in io.lines("/usr/local/nginx-1.4.2/data/rule.txt") do _,_,device_type, device_rule = string.find(item, "^(%a+)--(%a+)$") devicedb:set(device_type,device_rule) end ngx.say("ok") '; }
rule.txt文件格式
SAMSUNG--samRule APPLE--appRule XIAOMI--xiaRule
相关文章推荐
- Nginx + Lua + 共享内存实现动态查询(简单例子)
- Nginx + Lua + 共享内存实现动态查询(简单例子)
- nginx+redis+lua 共享内存
- Nginx + Lua + 共享内存实现动态查询(简单例子)
- Nginx + Lua + 共享内存实现动态查询(简单例子)
- nginx-lua worker 之间数据共享
- nginx源码学习4——重写共享内存锁类
- Nginx内存管理及数据结构浅析–共享内存的实现
- Nginx源码分析(1)之——共享内存的配置、分配及初始化
- nginx进程间的通信机制源码分析(一)----共享内存
- ngx_lua模块中的共享内存字典项API
- 2013.3.26 nginx 共享内存学习
- 一种openresty在init_by_lua_file阶段读取redis到共享内存的方法
- nginx - 共享内存与锁的实现
- Nginx内存管理及数据结构浅析–共享内存的实现
- linux 共享内存与nginx共享内存
- nginx--共享内存使用详解
- nginx之共享内存
- ngx_lua模块中的共享内存字典项API
- nginx 进程通信--共享内存