Hi,
The aim of this pr is to make resty.limit.count's incoming function using the latest type of shared dict's incr 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 https://github.com/openresty/lua-resty-limit-traffic/pull/34#issuecomment-765246987.
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 https://github.com/openresty/lua-resty-limit-traffic/pull/34#issuecomment-765246987.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 https://github.com/openresty/lua-resty-limit-traffic/issues/23#issuecomment-332912949 and https://github.com/openresty/lua-resty-limit-traffic/issues/47#issue-473159401). 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.