lua-resty-lock
lua-resty-lock copied to clipboard
Being able to set an expiration time per key, and not just per dict
Currently it's only possible to set an expiration time to the entire dictionary when creating a new instance:
local obj = resty_lock:new("locks_dict", {exptime = 10})
It would be nice to allow setting an expiration time per key too, like:
local obj = resty_lock:new("reports_locks")
obj:lock("test", {exptime = 10})
So that one dictionary can be used to set multiple keys with a different expiration time:
local obj = resty_lock:new("reports_locks")
obj:lock("test", {exptime = 10})
obj:lock("test2", {exptime = 4})
obj:lock("test3", {exptime = 50})
@thefosk I'd go for the simpler and more efficient form below:
obj:lock(key, timeout)
where the timeout
argument is optional (default to the value set in the constructor option).
@thefosk And patches welcome :)