本文基于
redis_version:6.2.5
用法
修改del
命令的默認(rèn)行為笼呆,使之與unlink
命令一毛一樣
lazyfree-lazy-user-del yes
?
注意事項(xiàng):
-
lazyfree-lazy-user-del
支持yes
或者no
诀姚。默認(rèn)是no
腮恩。 - 如果設(shè)置為
yes
含思,那么del
命令就等價(jià)于unlink
,也是非阻塞刪除纱意。
?
源碼實(shí)現(xiàn)
redis_del_lazyfree-lazy-user-del.png
del
與unlink
命令底層均調(diào)用delGenericCommand
方法俐东,區(qū)別是unlink
第二個(gè)參數(shù)傳的是1,del
傳的是lazyfree-lazy-user-del
痘系,所以如果lazyfree-lazy-user-del
配置的是yes
的話菲嘴,那么del
命令的功能就等價(jià)于unlink
。
?
原生注釋
# 翻譯概要:將代碼中的del替換成unlink可能不是那么太容易汰翠,所以為了讓del
# 命令的實(shí)際效果等價(jià)于unlink龄坪,你可以修改配置文件為lazyfree-lazy-user-del yes
#
# It is also possible, for the case when to replace the user code DEL calls
# with UNLINK calls is not easy, to modify the default behavior of the DEL
# command to act exactly like UNLINK, using the following configuration
# directive:
lazyfree-lazy-user-del no
本文屬于原創(chuàng),首發(fā)于微信公眾號(hào)【小易哥學(xué)呀學(xué)】复唤,如需轉(zhuǎn)載請(qǐng)后臺(tái)留言健田。