I am trying to implement a high performance thread-safe caching. Here is the code I have implemented. I don\'t want any on demand computing. Can I use cache.asMap() and retrieve
Guava contributor here:
Yes, that looks just fine, although I'm not sure what the point is of wrapping the cache in another object. (Also, Cache.getIfPresent(key)
is fully equivalent to Cache.asMap().get(key)
.)
If you want high performance, why don't you instanciate the Cache statically instead of using a synchronized getInstance()?