Search code examples
ignite

When is it better to use transactions, and when is it better to use distributed locks?


  1. When is it better to use transactions, and when is it better to use distributed locks?
  2. Can Transactions and distributed locks be used in multiple cache?
  3. Will transactions and distributed locks have any impact on persistence, such as ReadThrough and WriteThrough?

Waiting for the above three answers.


Solution

    1. They're different so it's difficult to say. If you need ACID transactions, use transactions. That's what they're there for
    2. Distributed locks are independent of caches. Transactions can work across multiple caches
    3. When using transactions, you have full two-phase commits, meaning that writes are either committed (or not) to both Ignite and the underlying database

    Note, I'm assuming you mean Ignite#reentrantLock() when you say "distributed locks." There's also IgniteCache#lock(), but that only for a single record and typically isn't what's required.