apr
Questions about Cachex
Hello!
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?
Thanks!
Marked As Solved
OvermindDL1
That’s what the Action Block transaction would be. execute just runs in the cache process for speed, but does not synchronization, transaction is what does synchronization. ![]()
Also Liked
OvermindDL1
Or /3 if no options needed yep:
https://hexdocs.pm/cachex/action-blocks.html#transaction-blocks
apr
Perfect, thanks @OvermindDL1!
apr
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.








