-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Milestone
Description
Goal
Implement the MSETEX command as described in Redis documentation.
Command Syntax
MSETEX numkeys key value [key value ...] [NX|XX] [EX seconds|PX milliseconds|EXAT timestamp|PXAT timestamp|KEEPTTL]
Implementation Details
-
Command Registration:
- Register
MSETEXinsrc/server/command_registry.cc(orstring_family.ccregistration block). - It should be a write command.
- Register
-
Implementation in
src/server/string_family.cc:- Implement a new function
MSetEx(or similar) to handle the command. - Argument Parsing:
- Parse
numkeysto determine how many key-value pairs to expect. - Parse the key-value pairs.
- Parse the optional arguments (expiration, NX/XX, KEEPTTL) into
SetCmd::SetParams.
- Parse
- Logic:
- The existing
OpMSetfunction currently iterates over keys and callsSetCmd::Setwith default parameters. - Refactor
OpMSetto acceptSetCmd::SetParamsas an argument, or create a newOpMSetExfunction that does so. - Ensure the operation is atomic (runs in a single hop/transaction), similar to
MSET. - Use
SetCmdclass which already handles the logic for setting values with options.
- The existing
- Implement a new function
-
Tests:
- Add unit tests in
src/server/string_family_test.cccovering:- Basic usage with expiration.
NXandXXoptions.KEEPTTLoption.- Invalid arguments (wrong
numkeys, invalid options). - Atomicity (all or nothing, though hard to test directly in unit tests, verify behavior).
- Add unit tests in
References
src/server/string_family.cc:OpMSet,SetCmdhttps://redis.io/docs/latest/commands/msetex/
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels