Skip to content

Commit ec4becf

Browse files
committed
bugfix: the exptime argument to shdict:set/add/etc methods was incorrectly ignored when the flags argument is also specified. thanks the patch from Brian Akins.
1 parent 81f1d7c commit ec4becf

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/ngx_http_lua_shdict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ ngx_http_lua_shdict_set_helper(lua_State *L, int flags)
591591
lua_typename(L, value_type));
592592
}
593593

594-
if (n == 4) {
594+
if (n >= 4) {
595595
exptime = luaL_checknumber(L, 4);
596596
if (exptime < 0) {
597597
exptime = 0;

t/043-shdict.t

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,3 +1019,27 @@ GET /test
10191019
199 number
10201020
10502 number
10211021
nil nil
1022+
1023+
1024+
1025+
=== TEST 43: expired entries (can be auto-removed by get), with flags set
1026+
--- http_config
1027+
lua_shared_dict dogs 1m;
1028+
--- config
1029+
location = /test {
1030+
content_by_lua '
1031+
local dogs = ngx.shared.dogs
1032+
dogs:set("foo", 32, 0.01, 255)
1033+
ngx.location.capture("/sleep/0.01")
1034+
local res, flags = dogs:get("foo")
1035+
ngx.say("res = ", res, ", flags = ", flags)
1036+
';
1037+
}
1038+
location ~ '^/sleep/(.+)' {
1039+
echo_sleep $1;
1040+
}
1041+
--- request
1042+
GET /test
1043+
--- response_body
1044+
res = nil, flags = nil
1045+

0 commit comments

Comments
 (0)