Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

PSETEX

Last updated
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.

Case RESP2 RESP3
Always Simple string OK Simple string OK

Errors:

  • ERR value is not an integer or out of range when milliseconds is not an integer.
  • ERR invalid expire time in 'psetex' command when milliseconds is zero, negative or too large.
127.0.0.1:6379> PSETEX lock:job 1500 "worker-2"
OK
127.0.0.1:6379> PTTL lock:job
(integer) 1500

Same as Redis 7 and Valkey 8.

SET, SETEX, PEXPIRE