isKeyInCache を使用して、ehcache で putIfAbsent メソッドを置き換えることはできますか?
これが私のテストコードです。パフォーマンスは大きく異なります
// putIfAbsent
time = System.nanoTime();
ehcache.putIfAbsent(new Element(assetUid, asset));
estimated = System.nanoTime();
System.out.println(estimated - time);
// isKeyInCache and put
time = System.nanoTime();
if (!ehcache.isKeyInCache(assetUid)) {
ehcache.put(new Element(assetUid, asset));
}
estimated = System.nanoTime();
System.out.println(estimated - time);
そしてコンソール出力
1693409
18235
それとも他の提案がありますか?ありがとうございました