A null multi-bulk reply returned by Redis is simply translated as NULL
by Predis, so when the client returns that from EXEC
instead of an array it means that the transaction has been aborted by the server. In your script you should just check if $result === null
(note the strict comparison) to safely catch aborted transactions.
Alternatively, instead of directly using MULTI
, EXEC
et al with Predis you can use a more high-level abstraction for transactions exposed by the Predis\Client::multiExec()
method, in a similar way to how it is used in this example with check-and-set and an optional automatic retry count for aborted transactions after which the client throws an exception.