PSETEX
PSETEX key milliseconds value
- Group
- String
- Complexity
- O(1)
- Arity
- 4 (exactly, counting the command name)
- Flags
- write
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
PSETEX stores value at key and makes it expire after milliseconds, in
one step. It is the same as SET key value PX milliseconds.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Always | Simple string OK |
Simple string OK |
Errors:
ERR value is not an integer or out of rangewhenmillisecondsis not an integer.ERR invalid expire time in 'psetex' commandwhenmillisecondsis zero, negative or too large.
Examples
Section titled “Examples”127.0.0.1:6379> PSETEX lock:job 1500 "worker-2"OK127.0.0.1:6379> PTTL lock:job(integer) 1500Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.