簡體   English   中英

點燃緩存事務和 putAsync

[英]Ignite cache transactioin and putAsync

我在事務中使用 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();

是的,commit() 將等待異步方法完成。 請注意,您只能同時運行一個異步方法 - 如果您有一個,下一個將同步運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM