{"acl_categories":["@keyspace","@write","@fast"],"arguments":[{"display_text":"key","key_spec_index":0,"multiple":true,"name":"key","type":"key"}],"arity":-2,"categories":["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],"command_flags":["write","fast"],"complexity":"O(1) for each key removed regardless of its size. Then the command does O(N) work in a different thread in order to reclaim memory, where N is the number of allocations the deleted objects where composed of.","description":"Asynchronously deletes one or more keys.","duplicateOf":"head:data-ai-metadata","group":"generic","key_specs":[{"RM":true,"begin_search":{"spec":{"index":1},"type":"index"},"delete":true,"find_keys":{"spec":{"keystep":1,"lastkey":-1,"limit":0},"type":"range"}}],"location":"body","since":"4.0.0","syntax_fmt":"UNLINK key [key ...]","title":"UNLINK","tableOfContents":{"sections":[{"id":"required-arguments","title":"Required arguments"},{"id":"examples","title":"Examples"},{"id":"redis-software-and-redis-cloud-compatibility","title":"Redis Software and Redis Cloud compatibility"},{"id":"return-information","title":"Return information"}]},"codeExamples":[]}
unlink(
keys: byte[]...
) → long// The number of keys that were unlinkedunlink(
key: byte[]
) → long// The number of keys that were unlinkedunlink(
keys: String...
) → long// The number of keys that were unlinkedunlink(
key: String
) → long// The number of keys that were unlinked
unlink(
keys: K...// the keys.
) → Long// Long integer-reply The number of keys that were removed.
unlink(
keys: K...// the keys.
) → RedisFuture<Long>// Long integer-reply The number of keys that were removed.
unlink(
keys: K...// the keys.
) → Mono<Long>// Long integer-reply The number of keys that were removed.
KeyDelete(
key: RedisKey, // The key to delete.flags: CommandFlags// The flags to use for this operation.
) → bool// true if the key was removed.KeyDelete(
keys: RedisKey[], // The keys to delete.flags: CommandFlags// The flags to use for this operation.
) → long// The number of keys that were removed.
KeyDeleteAsync(
key: RedisKey, // The key to delete.flags: CommandFlags// The flags to use for this operation.
) → Task<bool>// true if the key was removed.KeyDeleteAsync(
keys: RedisKey[], // The keys to delete.flags: CommandFlags// The flags to use for this operation.
) → Task<long>// The number of keys that were removed.
unlink(
$keyOrKeys: string[]|string,
...$keys: string
) → int
unlink(
*keys: String, Array<String>
) → Integer// number of keys that were unlinked
No method signature available for this client.
No method signature available for this client.
Available since:
Redis Open Source 4.0.0
Time complexity:
O(1) for each key removed regardless of its size. Then the command does O(N) work in a different thread in order to reclaim memory, where N is the number of allocations the deleted objects where composed of.
This command's behavior varies in clustered Redis environments. See the multi-key operations page for more information.
This command is very similar to DEL: it removes the specified keys.
Just like DEL a key is ignored if it does not exist. However the command
performs the actual memory reclaiming in a different thread, so it is not
blocking, while DEL is. This is where the command name comes from: the
command just unlinks the keys from the keyspace. The actual removal
will happen later asynchronously.
Required arguments
key [key ...]
One or more keys to delete asynchronously.
Examples
redis> SET key1 "Hello"
OK
redis> SET key2 "World"
OK
redis> UNLINK key1 key2 key3
(integer) 2
Redis Software and Redis Cloud compatibility
Redis Software
Redis Cloud
Notes
✅ Standard ✅ Active-Active
✅ Standard ✅ Active-Active
Return information
Integer reply: the number of keys that were unlinked.
Integer reply: the number of keys that were unlinked.