RANDOMKEY(3valkey)
π RANDOMKEY β the Valkey command manual, but make it a group chat π
okay so bestie, you know randomkey? it's a page in the Valkey Command Manual (that's the 3valkey section, mwah) and honestly? it's giving β¨main characterβ¨. let's get into it.
β¨ NAME β¨
randomkey β returns a random key name from the database. that's it. that's the whole vibe. no notes. π
πΈ SYNOPSIS πΈ
RANDOMKEY
Return a random key from the currently selected database. yes queen, just the one. no args, no flags, no drama. π
π¦ REPLY π¦
so here's the tea β what you get back depends on which RESP you're speaking, and ngl the answer is basically the same either way, just with different spelling for "nothing". π
RESP2
One of the following, periodt:
valkey-protocol(7)Nil reply: when the database is empty. (empty database = no key for you, bestie π)valkey-protocol(7)Bulk string reply: a random key in the database. π
RESP3
One of the following, and yes it's the same deal but the "empty" one is named differently, don't @ me:
valkey-protocol(7)Null reply: when the database is empty.valkey-protocol(7)Bulk string reply: a random key in the database.
β‘ COMPLEXITY β‘
literally constant time. instant. iconic. it ate and left no crumbs. π₯
π ACL CATEGORIES π
@keyspace@read@slow
three little tags and they're all slaying. π
π HISTORY π
- Available since:
1.0.0β she's been here since the very beginning, an OG fr fr. β
π«Ά SEE ALSO π«Ά
the whole friend group, no cap:
copy(3valkey), del(3valkey), dump(3valkey), exists(3valkey), expire(3valkey), expireat(3valkey), expiretime(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), 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)
go read them too, they're all baddies. π
lowkey the whole thing is:RANDOMKEY= one random key,O(1), done. but you already knew that. iykyk. π
okay that's the whole page!! π this was Valkey 9.0.0, dated 2025-10-21 β screenshot it, bookmark it, tell your friends. bye bestie, go grab a random key, 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