0

I'm using java 8 and guava 14.0

I set up a LoadingCache and a CacheLoader with a load(). The code works every time I get from the cache the load () is called

There are times where I want to check if data is in the cache without calling the load(). Is this possible?

I tried using the getIfPresent() but I still see the load() being called.

I was looking at AsMap but concerned with the size of this since it gets all the data from the cache

Thanks in advance for any info/suggestions

Barry

4

1 に答える 1

0

あなたの懸念が何なのかわかりませんasMap; コピー全体ではなくビューを返します。使用コストasMapは O(1) です。getIfPresentとはいえ、それでも負荷がかかるのは驚きです。プログラムの他の部分がロードを呼び出しているのではないかと疑っていますgetIfPresent

于 2015-10-30T21:12:27.837 に答える