Is Redis' set command an atomic operation?

早过忘川 提交于 2020-05-12 11:47:07

问题


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.



来源:https://stackoverflow.com/questions/43259635/is-redis-set-command-an-atomic-operation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!