Using Guava for high performance thread-safe caching

前端 未结 2 510
遥遥无期
遥遥无期 2021-02-18 17:59

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

相关标签:
2条回答
  • 2021-02-18 18:19

    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).)

    0 讨论(0)
  • 2021-02-18 18:29

    If you want high performance, why don't you instanciate the Cache statically instead of using a synchronized getInstance()?

    0 讨论(0)
提交回复
热议问题