Comments (4)
直接使用 openresty 的 ngx_lua 模块的 ngx.shared_dict 就可以做缓存了啊。
from nginx-openresty-windows.
userdata 不可以,lua 的 shared_dict 只支持 这几种类型的数据存储,number,boolean,string,所以最好的解决方法就是把 你的 userdata 序列化成一个字符串,然后传入,取出的时候再反序列化出来。
from nginx-openresty-windows.
Hi zqzjz0911:
首先非常感谢你的热心回复。我将c中的指针转为字符串后传入lua,并保存到shared_dict。但是跨越不同http request,这个指针是无效的。当然,一个http request中可以运行。所以,我估计,即使将worker设置为1个,在每次http request中,都有不同的堆栈和运行环境。同时,我认为以目前情况,openresty很难做到有状态的大数据量计算任务(例如在内存中的拓扑分析,先要建立拓扑结构,然后根据拓扑改变再计算。拓扑不是每次http request请求时重新建立的,数据量高达几十G),我本打算将openresty应用到这种场景中,但我还没有找到这样的方案。使用redis固然是一种办法,但序列化->存储->反序列化的过程耗时太长。不知道有大拿能够有办法没有。
最后说一下,在没有办法的情况下,我选择了FastCGI技术,然后用C++实现了数据缓存和计算的部分。前端使用Openrest做无状态、简单查询、交易类的命。重度计算则由openresty转到fastcgi执行。
from nginx-openresty-windows.
序列化指针会引起问题的,序列化整个对象才能跨进程,这样有状态的请求也是可以处理。可以考虑一下哈。
from nginx-openresty-windows.
Related Issues (20)
- 支持 IOCP 吗? HOT 4
- Nginx never start HOT 17
- 我想给nginx添加几个模块,有没有编译文档 HOT 5
- 请问这个要怎么解决? HOT 2
- 网盘下载不了? HOT 1
- lua file system不考虑支持下么.我用官方下的dll貌似不能正确加载呢 HOT 4
- ---------- HOT 8
- How to kill all of the nginx process? HOT 3
- balancer.set_timeouts()运行出错cannot resolve symbol 'ngx_http_lua_ffi_balancer_set_timeouts HOT 2
- Download Link down can you check address ? HOT 3
- iocp版怎么配置呢? HOT 7
- 我想把stream-lua-nginx-module模块编译进去,请问有没有编译好的版本或者编译编译文档? HOT 4
- nginx0.5.6至1.12.0,...等多版本存在信息泄漏漏洞 x1 HOT 4
- 请问一下你的objs/makefile文件是用工具生成的还是手工写的?如果手工写的话,添加一个模块岂不是很麻烦?如果是工具的话,请问用的啥工具? HOT 5
- 我在添加stream-lua-nginx-module模块的时候遇到这样的报错,请问你有遇到过吗?在nmake阶段的时候 HOT 3
- iocp版,IOCP下反向代理缓存模式,不能稳定访问 HOT 1
- 这个版本还发布么nginx都更新好多版本了,这个为啥没更新的? HOT 1
- 请问ngx cache purge 这个模块是否有考虑加入这个版本啊 HOT 1
- 工程项目能用 VS2013编译吗? HOT 1
- IOCP_1.11.5.1001 32位和64位版,访问postgres模块,nginx.exe会卡死,浏览器一直等待
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nginx-openresty-windows.