I want to “block” the code block optimistically. The psuedo code is as follows:
revision = GET('lock_key') # default as 0 { <<block of code>> } new_revision = INCR('lock_key') if new_revision != revision + 1: raise Exception # now retry or whatever
This looks good to me, since INCR and GET are atomic. Do you see any problems with this approach?
. -, , . , , , . , , INCRing key_lock.
Redis 'MULTI, EXEC WATCH. Redis ' psuedo:
WATCH('lock_key') revision = GET('lock_key') # default as 0 { <<block of code>> } MULTI() new_revision = INCR('lock_key') if EXEC() is None: raise Exception # now retry or whatever
Source: https://habr.com/ru/post/1540509/More articles:SPUtility.SendEmail () always returns false - c #Postfix не может получить закрытый ключ RSA из файла /etc/ssl/private/server.key: отключить поддержку TLS - linuxCSS - How to make a rectangle with pointed sides? - htmlDifferences in Python AES implementation - pythonError setting property values; Nested exception - org.springframework.beans.NotWritablePropertyException: - javaPort Sharing WCF net tcp - c #How to create an embedded dialog in MS CRM 2013 - javascriptWhat is the difference between the Adacore Gnat version and the "standard" version - adaMysql Inner Join Query - sqlСсылка на один элемент массива numpy - pythonAll Articles