Hello!
On Sun, Dec 15, 2013 at 4:43 AM, amnon.david wrote:
> However, I've noticed that it appears that the value of the
> entry expires after the period of the first ngx.shared.DICT.set operation,
> which means subsequent invocations of ngx.shared.DICT.set on the same key do
> not extend the lifetime of this key in the dictionary as I had expected.
>
set() overrides everything, including the expiration time. Consider
the following minimal example tested on my side:
location = /t {
content_by_lua '
local dogs = ngx.shared.dogs
dogs:set("foo", 32, 1)
ngx.sleep(0.5)
dogs:set("foo", 32, 1)
ngx.sleep(0.6)
local val = dogs:get("foo")
ngx.say(val, " ", type(val))
';
}
Then accessing /t gives
32 number
which is expected. The second set() call overrides (and thus extend)
the exptime. If we comment out the second set() call, accessing /t
yields
nil nil
The value is expired, also as expected.
Regards,
-agentzh