EXPIRETIME(3valkey)
π EXPIRETIME π (that's the page for expiretime, from the Valkey Command Manual, section 3valkey β bestie you're gonna love this one)
β¨ NAME β¨
expiretime β gives you back the expiration time of a key, as a Unix timestamp. that's it. that's the whole job. π
πΈ SYNOPSIS πΈ
EXPIRETIME key
one key. one answer. no drama. π
π¦ DESCRIPTION π¦
okay so picture this: you've got a key, and that key has a little countdown clock on it. EXPIRETIME reads that clock and tells you the absolute Unix timestamp (that means seconds since January 1, 1970, the og epoch, the moment time itself said "hey") at which your key is gonna expire. β°β¨
like, not "in 40 seconds", but "at 33177117420". absolute. final. iconic.
also, if you want the same tea but with millisecond resolution, go look at the valkey-pexpiretime(7) PEXPIRETIME command. same info, finer detail, still slay. π
π REPLY π
you're gonna get one of these three, and they're all valkey-protocol(7) integer replies, no cap:
valkey-protocol(7)Integer reply β the expiration Unix timestamp, in seconds. the actual answer, the main character. πvalkey-protocol(7)Integer reply β-1if the key exists but has no associated expiration time. like, she's alive but she's immortal. no clock, no expiry. πvalkey-protocol(7)Integer reply β-2if the key does not exist. rip. she's not even here. π
β‘ COMPLEXITY β‘
constant time. instant. faster than your ex replying to a text. π₯
π ACL CATEGORIES π
@fast @keyspace @read
fast, keyspace-y, read-only. the holy trinity of "i'm just looking, i promise." π«Ά
π HISTORY π
- Available since:
7.0.0β so she's a newer girly, born in the 7.0.0 era. π
π EXAMPLES π
here's the whole vibe, verbatim, go off:
127.0.0.1:6379> SET mykey "Hello"
OK
127.0.0.1:6379> EXPIREAT mykey 33177117420
(integer) 1
127.0.0.1:6379> EXPIRETIME mykey
(integer) 33177117420
so we set mykey to "Hello", then EXPIREAT pins its death date to 33177117420, and then EXPIRETIME reads it right back at us. 33177117420. consistency ate. π
π SEE ALSO π
the whole friend group, fr fr:
copy(3valkey), del(3valkey), dump(3valkey), exists(3valkey), expire(3valkey), expireat(3valkey), keys(3valkey), migrate(3valkey), move(3valkey), object(3valkey), object-encoding(3valkey), object-freq(3valkey), object-help(3valkey), object-idletime(3valkey), object-refcount(3valkey), persist(3valkey), pexpire(3valkey), pexpireat(3valkey), pexpiretime(3valkey), pttl(3valkey), randomkey(3valkey), rename(3valkey), renamenx(3valkey), restore(3valkey), scan(3valkey), sort(3valkey), sort_ro(3valkey), touch(3valkey), ttl(3valkey), type(3valkey), unlink(3valkey), wait(3valkey), waitaof(3valkey)
lowkey a note:EXPIRETIMEgives you the absolute timestamp, not a countdown. if you wanted "how many seconds left", that's a different girly (TTL). don't mix them up bestie, iykyk. π
okay that's the whole page!! π this one's from Valkey version 9.0.0, dated 2025-10-21 β so go forth, check your expirations, and stay iconic. mwah. π
β¨ππ¦
π¦ 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