feat: resty.limit.count support new shared dict incr function #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
The aim of this pr is to make
resty.limit.count
's incoming function using the latest type of shared dict'sincr
function, which supports setting expire time when increasing an unexisting key, and it is also compatible with the old version of OpenResty, just as mentioned in #34 (comment).I'm doing some pressure tests recently to test the stability of lua-resty-limit-traffic module and found some problems under high volume(possibly due to the concurrent situation and two separate atomic operation(incr and expire) calls in
incoming
, see #23 (comment) and #47 (comment)). However, I found that when I'm using the latestincr
function which supports expire time(which makes the two operation combines into an atomic one(done within the same lock, see https://github.com/openresty/lua-nginx-module/blob/3f33dd862a3d8539b96dda09b624c89712cbe0c8/src/ngx_http_lua_shdict.c#L1889), the problem hardly occurs. So I think it is perhaps a good idea to use incr with expire time arg instead of separate them into two operations.