如何原子地执行这些操作?
def setNickName(nick):
oldNick = r.get("user:id:1:nick") # r - instance of redis.Redis()
updated = r.set("user:id:1:nick", nick) if r.hsetnx("user:ref:nick", nick, '1') else False
if updated and oldNick:
r.hdel("user:ref:nick", oldNick)
return True
return False