UNLINK(3valkey)
β¨ UNLINK β the valkey manual page, bestie edition β¨
okay so welcome to UNLINK(3valkey), straight out of the Valkey Command Manual π this one's short, it's sweet, and it's lowkey a glow-up of DEL. let's get into it π«Ά
πΈ NAME πΈ
unlink β deletes one or more keys, but asynchronously. like, it said it would do it, and it will, justβ¦ later π
π SYNOPSIS π
UNLINK key [key...]
π¦ DESCRIPTION π¦
okay so this command is very similar to valkey-del(7) DEL β it removes the keys you name. and just like DEL, if a key doesn't exist, it gets ignored, no drama, no error, nothing π
but here's the plot twist, bestie: UNLINK does the actual memory reclaiming in a different thread, so it is not blocking, whereas DEL is blocking. that's literally where the name comes from β the command just unlinks the keys from the keyspace, and the actual removal happens later, asynchronously. it's giving "I'll deal with it tomorrow" but make it a database π
π REPLY π
valkey-protocol(7) Integer reply: the number of keys that were unlinked. so like, a lil count of how many keys got the boot β¨
π₯ COMPLEXITY π₯
- O(1) for each key removed, regardless of its size. iconic, no cap.
- then the command does O(N) work in a different thread to reclaim memory, where N is the number of allocations the deleted objects were composed of. so the expensive part is off doing its own thing in the background π
π ACL CATEGORIES π
@fast @keyspace @write
β HISTORY β
- Available since: 4.0.0 (a classic, fr fr)
π EXAMPLES π
127.0.0.1:6379> SET key1 "Hello"
OK
127.0.0.1:6379> SET key2 "World"
OK
127.0.0.1:6379> UNLINK key1 key2 key3
(integer) 2
notice how key3 never existed and nobody made a big deal about it? yeah. ignored. it returned 2 because only two keys were actually there to unlink π
ate and left no crumbs.
π SEE ALSO π
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), randomkey(3valkey), rename(3valkey), renamenx(3valkey), restore(3valkey), scan(3valkey), sort(3valkey), sort_ro(3valkey), touch(3valkey), ttl(3valkey), type(3valkey), wait(3valkey), waitaof(3valkey)
and that's the whole page, bestie π§ this was Valkey 9.0.0, dated 2025-10-21. go unlink something, but like, responsibly πβ¨
π¦ 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