Skip to content

shared.DICT and expiration time #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bungle opened this issue Aug 24, 2015 · 12 comments
Closed

shared.DICT and expiration time #552

bungle opened this issue Aug 24, 2015 · 12 comments

Comments

@bungle
Copy link
Member

bungle commented Aug 24, 2015

I would like to see a way to retrieve and set shared dictionary expiration time.

E.g.

value, flags, exptime = ngx.shared.DICT:get(key)
-- it would be nicer to have same order as in set (but that would break bc):
value, exptime, flags = ngx.shared.DICT:get(key)

Or

exptime = ngx.shared.DICT:expires(key)

And

success, err = ngx.shared.DICT:expire(key, exptime)

Does it make sense or is it unneccessarely difficult and bloat?

@agentzh
Copy link
Member

agentzh commented Aug 27, 2015

@bungle Maybe we can just borrow the redis command names here? i.e.,

local exptime, err = dict:ttl(key)
local ok, err = dict:expire(key, seconds)

The direction is to support more and more redis commands in lua_shared_dict in the future :)

@bungle
Copy link
Member Author

bungle commented Aug 27, 2015

@agentzh, oh, I had forgotten that for lua_shared_dict you had such a broad goals. That would work just as well. I kinda had / have an use case for this, and that's why I asked. You see I have been adding pluggable storage adapters to lua-resty-session. One of the adapters is shm that uses lua_shared_dict, as you can see here:

https://github.com/bungle/lua-resty-session/blob/storages/lib/resty/session/storage/shm.lua#L31

The line 31 is really just updating the expiration time, and it is unneccessary to update the value at that point.

@agentzh
Copy link
Member

agentzh commented Aug 27, 2015

@bungle Fair enough :) Will you contribute a patch for this feature?

@bungle
Copy link
Member Author

bungle commented Aug 27, 2015

I will look at it.

@agentzh
Copy link
Member

agentzh commented Aug 27, 2015

Cool, thanks!

@navneet-flipkart
Copy link

Even I felt the need of such a feature. Any update on whether this is available in any release?

@agentzh
Copy link
Member

agentzh commented Mar 21, 2016

@navneet-flipkart Not yet. The PR is still being reviewed.

@guanhui07
Copy link

queue

@h1z3y3
Copy link

h1z3y3 commented Aug 31, 2016

queue... I need it

@junos
Copy link

junos commented Oct 11, 2016

Need this as well

@agentzh
Copy link
Member

agentzh commented Oct 11, 2016

@guanhui07 @GitZhaoYang the shdict list data type support has already been released in the latest OpenResty version 1.11.2.1.

@junos I'm not sure what you are referring to. This ticket is more about expiration time, isn't it?

@thibaultcha
Copy link
Member

Done in #140 - we can close this

@agentzh agentzh closed this as completed Feb 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants