-
Notifications
You must be signed in to change notification settings - Fork 23.5k
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
Possibility of Hash/Set/List fields expiration #242
Comments
Hi, this will not be implemented by original design:
The reasoning is much more complex and is a lot biased by personal feelings, preference and sensibility so there is no objective way I can show you this is better ;) Closing. Thanks for reporting. |
Is there a best practice for approaching this? |
I have come up with a pretty good work-around solution for this "expire redis hash values by key" problem. Essentially you just store the entries with the timestamps as the keys, or embedded into the keys. Note that redis wants strings as keys so you'll have to .toString() / parseInt() the keys to do compares. Using this scheme, you just make a bunch of hash tables with your relevant variables in the names of the hash tables, and each one has timestamp/value pairs. For example, in nodejs:
Note that just deleting the old entries before you do any critical analysis on the values, as you go, is far more efficient, computationally, than having redis actually check timeout values on every key in every redis hash in every DB every second. So, it's not a bad solution. |
[5.0.1] add tarball tests
Now it's possible to set expiration only for keys to main objects, not for collecion elements.
I have design problem with that.
Let's imagine we store session properties in the hash.
Session expires after some time, but we have to know how many sessions are still alive.
So... | created another collection to store active session list, where:
token (key), and key to session hash (value).
Now, when my session expires, it's token in active collection is still present,
and I have no posiibility to remove them.
Solutions:
Possibility of Hash/Set/List fields expiration. I wille simply set expiration of session token, the same like main session hash
Expiration triggers - when key expires, some command group wille be executed (Maybe Lua script)
Publish expiration message to earlier defined channel, containing expired key. Using drivers I could implements my own triggers
The text was updated successfully, but these errors were encountered: