openresty / openresty/lua-resty-lrucache
BUG: The expiration time may not take effect
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 461
- Forks
- 114
- PR merge metrics
- No merged PRs in 30d
Description
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()?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lrucache's get method and the reported expiration check using ngx_now(). Reproduce the set/get sequence with os.execute("sleep " .. tonumber(ttl+2)), then verify whether the cached time is refreshed before expiration is evaluated; done means the entry is stale and data is nil after the TTL has elapsed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100