EsRedisTransactionAbortedException
Description
This exception is signaled when a Redis transaction is aborted. This is a specific failure condition that occurs when a key being watched via the WATCH
command is modified by another client after it has been watched but before the transaction has been executed with EXEC.
This is Redis's mechanism for optimistic locking. When this exception is caught, it indicates that the transaction did not run, and the application should typically retry the entire read-modify-write cycle.
Public API and Key Responsibilities
Usage Example
| client1 client2 |
client1 := EsRedisClient host: '127.0.0.1' port: 6379.
client2 := EsRedisClient host: '127.0.0.1' port: 6379.
client1 connect.
client2 connect.
client1 strings set: 'account_balance' value: 100.
client1 server watch: 'account_balance'.
"Another client interferes, changing the value"
client2 strings set: 'account_balance' value: 500.
[
"This transaction will be aborted by Redis and raise this exception"
client1 transaction: [:tx |
tx strings set: 'account_balance' value: 80
]
]
on: EsRedisTransactionAbortedException
do: [:ex | Transcript show: 'Transaction aborted as expected!'].
Class Methods
None
Instance Methods
None
Last modified date: 01/22/2026