psetex.3valkey - Man Page
Sets both string value and expiration time in milliseconds of a key. The key is created if it doesn’t exist.
Synopsis
PSETEX key milliseconds value
Description
PSETEX works exactly like SETEX with the sole difference that the expire time is specified in milliseconds instead of seconds.
Alternative
SET with the PX argument.
Reply
valkey-protocol(7) Simple string reply: OK.
Complexity
O(1)
Acl Categories
@slow @string @write
History
- Available since: 2.6.0
Examples
127.0.0.1:6379> PSETEX mykey 1000 "Hello" OK 127.0.0.1:6379> PTTL mykey (integer) 990 127.0.0.1:6379> GET mykey "Hello"
See Also
append(3valkey), decr(3valkey), decrby(3valkey), delifeq(3valkey), get(3valkey), getdel(3valkey), getex(3valkey), getrange(3valkey), getset(3valkey), incr(3valkey), incrby(3valkey), incrbyfloat(3valkey), lcs(3valkey), mget(3valkey), mset(3valkey), msetnx(3valkey), set(3valkey), setex(3valkey), setnx(3valkey), setrange(3valkey), strlen(3valkey), substr(3valkey)
Info
2025-10-21 9.0.0 Valkey Command Manual