PSETEX(3valkey)
π PSETEX π
okay bestie, welcome to psetex β it's from the Valkey Command Manual and it's literally the moment your key gets a value and a lil countdown, in milliseconds. slay.
β¨ NAME β¨
psetex β sets both the string value and the expiration time in milliseconds of a key. the key gets created if it doesn't exist yet. no cap. π
πΈ SYNOPSIS πΈ
PSETEX key milliseconds value
π¦ DESCRIPTION π¦
so here's the tea: PSETEX works exactly like SETEX with one (1) single difference β the expire time is given in milliseconds instead of seconds. that's it. that's the whole glow-up. β±οΈ
π Alternative
you could also just use SET with the PX argument. same vibe, different font. π«Ά
π REPLY π
valkey-protocol(7) Simple string reply: OK.
that's the whole reply. iconic behavior honestly.
β‘ COMPLEXITY β‘
O(1) β constant time, she's fast, she's efficient, she's not doing anything extra. π
π ACL CATEGORIES π
@slow@string@write
π HISTORY π
- Available since:
2.6.0β an elder, a legend, a founding mother. β
π EXAMPLES π
watch her work:
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"
likeβ¦ 1000 ms later and PTTL is already down to 990?? the way time just moves. ππ°οΈ
π SEE ALSO π
the whole friend group, fr fr:
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)
and that's the whole page bestie π this was version 9.0.0, dated 2025-10-21, from the Valkey Command Manual. go set a key with a millisecond timer on it, you absolute main character. periodt. π β¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms