Sorry if this is obvious, but I couldn’t find an answer in the docs.
I am using the Cachex library. How does one go about locking a row? Is it done via transaction/4? Is there a more lightweight version where I can just lock a row, perform some operation, and then unlock it?
If by locking a row you mean locking a key/value entry? That would be an Action Block. The execution block just runs the code in the context of the cache itself, thus much faster, though not transactional across ‘everything’, the transactional is transactional on the state of the cache however. Or are you referencing something?
Just for posterity’s sake, Cachex.get_and_update/4 has an implicit transaction underneath. So for this particular operation, transactions are not needed, but @OvermindDL1 's answer is the way to go for operations that do need transactions.