New MSETEX command allows to set an expiration time with MSET#3121
Conversation
It's a combination of MSET and EXPIRE, which allows us to set an expiration time simultaneously with the MSET operation. Syntax for the new MSETEX command: ``` /* MSETEX numkeys key value [key value ...] [NX | XX] * [EX seconds | PX milliseconds | * EXAT seconds-timestamp | PXAT milliseconds-timestamp | KEEPTTL] */ ``` The MSETEX command supports a set of options (like SET command): - EX seconds -- Set the specified expire time, in seconds (a positive integer). - PX milliseconds -- Set the specified expire time, in milliseconds (a positive integer). - EXAT timestamp-seconds -- Set the specified Unix time at which the keys will expire, in seconds (a positive integer). - PXAT timestamp-milliseconds -- Set the specified Unix time at which the keys will expire, in milliseconds (a positive integer). - KEEPTTL -- Retain the time to live associated with the keys. - NX -- Only set the keys if all keys do not already exist. - XX -- Only set the key if all keys already exists. Return Value (like MSETNX command): - Integer reply: 0 if no key was set due to NX or XX options. - Integer reply: 1 if all the keys were set. Signed-off-by: Binbin <binloveplay1314@qq.com>
|
Redis added this command in 8.4, and i've also received requests indicating that people want to use it in Valkey. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3121 +/- ##
============================================
- Coverage 75.02% 74.99% -0.03%
============================================
Files 129 129
Lines 71632 71681 +49
============================================
+ Hits 53739 53759 +20
- Misses 17893 17922 +29
🚀 New features to boost your workflow:
|
|
We have already discussed this in the core team meeting. I don't remember exactly why, but it it seems that the maintainers are not interested: #2592 (comment) @enjoy-binbin If you want to discuss this again, I think you need to find some new information that is not already mentioned in the issue, such as a strong use case or that you have requests from users. |
|
@enjoy-binbin so will we add some test for this command? or we rely only on fuzzer tests? |
I will add some tests for sure, just need some times. |
…ast key This issue was encountered while processing valkey-io#3121. Currently in all our commands with KSPEC_FK_KEYNUM, key step is 1. So this bug does not currently affect any core commands. If we have commands with different key step values, calculting the last key in here will casue problems since we are not including step in the calculation. Signed-off-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Binbin <binloveplay1314@qq.com>
…ast key (#3197) This issue was encountered while processing #3121. Currently in all our commands with KSPEC_FK_KEYNUM, key step is 1. So this bug does not currently affect any core commands. If we have commands with different key step values, calculting the last key in here will casue problems since we are not including step in the calculation. Signed-off-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Binbin <binloveplay1314@qq.com>
ranshid
left a comment
There was a problem hiding this comment.
LGTM.
Added some small comment on the tests (which are very defensive :) )
Signed-off-by: Binbin <binloveplay1314@qq.com>
|
@enjoy-binbin I am good with this version. I think we can merge it |
|
@ranshid Thank you for the review! I myself will take a final look and review the code again this week, and then i will merge it. |
ACK |
Signed-off-by: Binbin <binloveplay1314@qq.com>
|
I think we are good to go. @valkey-io/core-team Does any of you want to take a quick final look before the merge? |
Signed-off-by: Binbin <binloveplay1314@qq.com>
|
I don't need to review, but please fix the failing test case before merge. |
…ast key (valkey-io#3197) This issue was encountered while processing valkey-io#3121. Currently in all our commands with KSPEC_FK_KEYNUM, key step is 1. So this bug does not currently affect any core commands. If we have commands with different key step values, calculting the last key in here will casue problems since we are not including step in the calculation. Signed-off-by: Binbin <binloveplay1314@qq.com> Signed-off-by: Harkrishn Patro <bunty.hari@gmail.com>
|
@enjoy-binbin maybe last sync with unstable would yield a cleaner test verification? |
Signed-off-by: Binbin <binloveplay1314@qq.com>
- Fix release date to Mon Mar 18 2026 - Fix typos: duplicate 'load', 'keyes' -> 'keys', duplicate 'INFO' - Remove reverted contributor (arshidkv12, valkey-io#3137) - Add 7 new release-notes entries from upstream/unstable merge: CLUSTERSCAN (valkey-io#2934), MSETEX (valkey-io#3121), availability-zone (valkey-io#3156), stream range optimization (valkey-io#3002), RDB as AOF preamble (valkey-io#1901), unsigned 64-bit module config (valkey-io#1546), fast_float -> ffc (valkey-io#3329) Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
It's a combination of MSET and EXPIRE, which allows us to set an expiration time simultaneously with the MSET operation. Syntax for the new MSETEX command: ``` /* MSETEX numkeys key value [key value ...] [NX | XX] * [EX seconds | PX milliseconds | * EXAT seconds-timestamp | PXAT milliseconds-timestamp | KEEPTTL] */ ``` The MSETEX command supports a set of options (like SET command): - EX seconds -- Set the specified expire time, in seconds (a positive integer). - PX milliseconds -- Set the specified expire time, in milliseconds (a positive integer). - EXAT timestamp-seconds -- Set the specified Unix time at which the keys will expire, in seconds (a positive integer). - PXAT timestamp-milliseconds -- Set the specified Unix time at which the keys will expire, in milliseconds (a positive integer). - KEEPTTL -- Retain the time to live associated with the keys. - NX -- Only set the keys if all keys do not already exist. - XX -- Only set the keys if all keys already exists. Return Value (like MSETNX command): - Integer reply: 0 if no key was set due to NX or XX options. - Integer reply: 1 if all the keys were set. Closes #2592 --------- Signed-off-by: Binbin <binloveplay1314@qq.com>
See valkey-io/valkey#3121 Signed-off-by: Binbin <binloveplay1314@qq.com>
It's a combination of MSET and EXPIRE, which allows us to set an expiration
time simultaneously with the MSET operation.
Syntax for the new MSETEX command:
The MSETEX command supports a set of options (like SET command):
integer).
expire, in seconds (a positive integer).
will expire, in milliseconds (a positive integer).
Return Value (like MSETNX command):
Closes #2592