Is the UNLINK command always better than DEL?

Redis 4.0 introduces a new UNLINK command to remove keys in Redis memory.

This command is very similar to DEL: it deletes the specified keys. Like DEL, a key is ignored if it does not exist. However, the team performs the actual recovery of the memory in a different thread , so it is not blocked, and the DEL - . Here, the command name comes from: the command simply drops the keys from the key space. the actual deletion will happen asynchronously later.

Thus, it is always possible (100% times) to use UNLINK instead of DEL , since UNLINK is not blocked, unlike DEL, on the right?

+4
source share
2 answers

Before discussing which one is better, let's take a look at the difference between these teams. Both DELand UNLINKrelease a key part in the lock mode. And the difference is how they release value.

DELalways releases part of the value in lock mode. However, if the value is too large, i.e. too many distributions for big LISTor HASH, it blocks Redis for a long time. To solve the problem, Redis implements the command UNLINK, i.e. Non-blocking deletion.

UNLINK /. , .. LIST HASH 64, . , UNLINK DEL, , , DEL. , , Redis , , . , , .

, , DEL , UNLINK. , .. LIST , UNLINK , DEL. DEL UNLINK. , , ( ), DEL.

+1

. , Lazy Redis Redis antirez. , unlink - . unlink , del.

UNLINK - : , , , DEL, ASAP. .

, , - redis: DEL , UNLINK , . redis.

+2

Source: https://habr.com/ru/post/1684227/


All Articles