-
Notifications
You must be signed in to change notification settings - Fork 1k
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
SADDEX
option to update an existing member's TTL
#4676
Comments
Have you looked at https://www.dragonflydb.io/docs/command-reference/generic/fieldexpire @jgaskins ? would it help? |
I did forget about that one. It would save me from having to remove members from the set, but wouldn't avoid the need for a second command per label/value pair. This is possible with I did consider using hashes instead of sets for this for that reason, but assumed sets would have a smaller footprint. |
what is is the "label" and what is the "value" in your I actually was not aware of this undocumented difference in the behavior between hsetex and setex and I think I understand now the semantics you ask for. I think it makes sense. For the protocol, it's something like this in c++ pseudo code: auto [it, added] = set->insert(member, ttl);
if (!added)
it->ttl = ttl;
Here is what I suggest:
@jgaskins what do you think? |
Apologies, the set keys are an index of label/value pairs. So for example, So if I'm ingesting a metric that has the normalized labels
It surprised me, too, when I saw the set members expiring despite metrics for those time series coming in steadily.
Yes, this is pretty much exactly what I need. 💯
I really like this plan. The synergy with |
Did you search GitHub Issues and GitHub Discussions First?
Yes, there is only one open issue for
SADDEX
.Is your feature request related to a problem? Please describe.
I have a use case for upserting a member to a set with an expiration and applying that expiration regardless of whether the set already has that member — basically refreshing the TTL each time the member is upserted.
I am currently working around it by removing and reinserting it in a
MULTI
block:But ideally this could be atomic with a single command.
Describe the solution you'd like
I think an option like this might work:
I'm not too concerned about what the option is called. I'm just calling it
REFRESH
at the moment because I can't come up with anything else.Describe alternatives you've considered
Originally, I wanted it after the members' TTL:
But if we do that,
REFRESH
being an option or a value to add to the set is ambiguous. Either the option doesn't do anything or you can't add a member called"REFRESH"
to a set viaSADDEX
. I feel like it has to come before the TTL because it must be an integer, so if the server seesSADDEX REFRESH <integer> member ...
there is no ambiguity.I feel like
REFRESH
(or whatever the option ends up being called) must come before the TTL so there is no ambiguity.Additional context
My use case is that
SADDEX
is an important part of ingesting time series data. The time series are stored in streams, and each time series represents a set oflabel=value
pairs. I don't want the references to the streams to expire with data in those streams, so I need the TTL to be updated every time I record a measurement.Since I'm currently working around it with
SREM
+SADDEX
, if this option is added ingesting metrics will only require about half as many commands sent to the server, allowing close to double the ingestion rate for a given set oflabel=value
pairs.The text was updated successfully, but these errors were encountered: