【问题标题】:Ignite cache transactioin and putAsync点燃缓存事务和 putAsync
【发布时间】:2020-02-14 20:53:42
【问题描述】:

我将 Apache Ignite Cache 用于事务。目前我使用常规的 cache.put() 方法,但想知道我是否应该更好地使用推荐的 putAsync()?如果使用异步方法,Transaction.commit() 是等待所有异步放置完成还是我必须在我的代码中执行此操作?

这将是我的简化代码:

Ignite ignite = Ignition.ignite();
IgniteTransactions transactions = ignite.transactions();
tx = transactions.txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE, 10 * 1000, 0);

IgniteFuture fut = cache.putAsync("KEY", "VALUE");

fut.get(); // do I need to call this?

tx.commit();

【问题讨论】:

    标签: java ignite


    【解决方案1】:

    是的,commit() 将等待异步方法完成。请注意,您只能同时运行一个异步方法 - 如果您有一个,则下一个将同步运行。

    【讨论】:

      猜你喜欢
      • 2023-03-26
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      • 2017-10-15
      • 2023-04-09
      相关资源
      最近更新 更多