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.

This commit is contained in:
agentzh (章亦春) 2012-02-23 15:10:33 +08:00
Родитель 81f1d7ca4a
Коммит ec4becfead
2 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -591,7 +591,7 @@ ngx_http_lua_shdict_set_helper(lua_State *L, int flags)
lua_typename(L, value_type));
}
if (n == 4) {
if (n >= 4) {
exptime = luaL_checknumber(L, 4);
if (exptime < 0) {
exptime = 0;

Просмотреть файл

@ -1019,3 +1019,27 @@ GET /test
199 number
10502 number
nil nil
=== TEST 43: expired entries (can be auto-removed by get), with flags set
--- http_config
lua_shared_dict dogs 1m;
--- config
location = /test {
content_by_lua '
local dogs = ngx.shared.dogs
dogs:set("foo", 32, 0.01, 255)
ngx.location.capture("/sleep/0.01")
local res, flags = dogs:get("foo")
ngx.say("res = ", res, ", flags = ", flags)
';
}
location ~ '^/sleep/(.+)' {
echo_sleep $1;
}
--- request
GET /test
--- response_body
res = nil, flags = nil