I'm trying to use Redis' set
command to implement a simplest distributed lock component, but I can't find any exact basis about atomicity through the official document, is Redis' SET key value [EX seconds] [PX milliseconds] [NX|XX]
command an atomic operation?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes. The core is single threaded, so nothing will run until the SET
has completed; that makes SET {key} {value} EX {expiry} NX
ideal for simple locking.