lua-resty-lrucache icon indicating copy to clipboard operation
lua-resty-lrucache copied to clipboard

BUG: The expiration time may not take effect

Open Mhaoyuan opened this issue 3 years ago • 0 comments

lrucache:set(key, value, ttl, flags) os.execute("sleep " .. tonumber(ttl+2)) local data, stale_data, flags = lrucache:get(key) data is not nil

lruchache' get method if node.expire >= 0 and node.expire < ngx_now() then return nil, val, node.user_flags end

ngx_now() Returns a floating-point number for the elapsed time in seconds (including milliseconds as the decimal part) from the epoch for the current time stamp from the Nginx cached time (no syscall involved unlike Lua's date library). https://github.com/openresty/lua-nginx-module#ngxnow

Is it better to add an ngx.update_time()?

Mhaoyuan avatar Dec 25 '20 07:12 Mhaoyuan