Comments (4)
1 What happens when a key expires?
When and how and after how long is the memory replaced by this value freed and is it freed at all?
Nothing happens when a key expires. The expired key is still there if it is not replaced by another new add/set operation.
2 When memory is full, does the set method try to delete expired keys or can it delete keys that haven't expired yet?
There are different APIs.
When memory is full, the dict:set() will delete keys that is not expired yet.
And the dict:safe_set() will not delete keys that is not exipred.
from lua-nginx-module.
Thank you for the answer.
I understand correctly, if I want memory not to overflow I should take care of periodic calls of flush_expired() myself ?
http {
,,,,
lua_shared_dict my 1m;
init_by_lua_block {
local function mem_free()
ngx.shared.my:flush_expired()
end
require("resty.concurrent.scheduler").every("1h", mem_free)
}
....
}
P.S. The “resty.concurrent.scheduler” module is a figment of ChatGPT's imagination.
from lua-nginx-module.
Nope.
What you need to do is:
- config a reasonable shdict size
- choose the right API like set or safe_set
- set a reasonable expired time
If the shdict still overflows, then tweak the above steps.
from lua-nginx-module.
But if I set the test key to 3600 sec.
And no one will access (:get("test")) it after expiration, it will hang in memory forever until nginx is rebooted.
And so it is with every key.
Or did I misunderstand?
from lua-nginx-module.
Related Issues (20)
- Problem with post request reading in balancer_by_lua_block HOT 2
- huge size response via ngx.location.capture has been truncated HOT 1
- Search in POST request HOT 2
- issue use lua code beside modsecurity module HOT 2
- bug: the connection won't be closed normally when set arg[1] = "" HOT 1
- LUA_PATH must contain /usr/share/lua and /usr/lib/x86_64-linux-gnu/lua/
- the docs site doesn't reflect the updated features in the module
- time filter for shdict get_keys HOT 2
- conditional shm get, eagain HOT 3
- Aborting Nginx reload on condition HOT 1
- 500 Internal Server Error HOT 1
- ngx.say not work
- init_by_lua during Nginx config test HOT 3
- Using outer scope required modules inside an ngx.timer.at handler HOT 4
- when header_filter_by_lua_file run failed.
- OpenResty keepalive connection appears to be hung HOT 6
- unexpected phase error when `ngx.send_header()` trigger `if_unmodified` 412 logic HOT 2
- nginx: [emerg] dlopen() "/etc/nginx/ngx_http_naxsi_module.so" failed (/etc/nginx/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 nginx: configuration file /etc/nginx/nginx.conf test failed
- nginx: [emerg] dlopen() "/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so" failed (/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 HOT 2
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 lua-nginx-module.