MSETEX
Syntax
MSETEX numkeys key value [key value ...] [NX | XX] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]
- Available since:
- Redis Open Source 8.4.0
- Time complexity:
- O(N) where N is the number of keys to set.
- ACL categories:
-
@write,@string,@slow,
Atomically sets multiple string keys with an optional shared expiration in a single operation. Supports flexible argument parsing where condition and expiration flags can appear in any order.
Required arguments
numkeys
The number of keys being set.
key value [key value ...]
A series of key/value pairs.
Optional arguments
condition and expiration flags
The MSETEX command supports a set of options that modify its behavior:
NX-- Set the keys and their expiration time only if none of the specified keys exist.XX-- Set the keys and their expiration time only if all of the specified keys already exist.EX seconds-- Set the specified expiration time in seconds (a positive integer).PX milliseconds-- Set the specified expiration time in milliseconds (a positive integer).EXAT unix-time-seconds-- Set the specified Unix time in seconds (a positive integer) at which the key(s) will expire.PXAT unix-time-milliseconds-- Set the specified Unix time in milliseconds (a positive integer) at which the key(s) will expire.KEEPTTL-- Retain the time to live associated with the keys.
Redis Software and Redis Cloud compatibility
| Redis Enterprise |
Redis Cloud |
Notes |
|---|---|---|
| ❌ Standard |
❌ Standard |
Return information
Integer reply: 0 if none of the keys were set; 1 if all of the keys were set.