4

I am caching data in a singleton ejb using google cache. And the cached resources are used by multiple ejbs. But now am not sure if the same application will work if deployed in a multinoded clustered environment where multiple JVMs can be present.

Please advise!

mfulton26
  • 29,956
  • 6
  • 64
  • 88
user1455719
  • 1,045
  • 4
  • 15
  • 35

1 Answers1

6

No, Guava Cache is not suitable for your use case, because it stores data in memory. See this wiki page:

Generally, the Guava caching utilities are applicable whenever:

  • You are willing to spend some memory to improve speed.
  • You expect that keys will sometimes get queried more than once.
  • Your cache will not need to store more data than what would fit in RAM. (Guava caches are local to a single run of your application. They do not store data in files, or on outside servers. If this does not fit your needs, consider a tool like Memcached.)

I can recommend you using Ehacache, it's very powerful and configurable.

Grzegorz Rożniecki
  • 27,415
  • 11
  • 90
  • 112
  • 1
    There are also many other distributed cache solutions. EHCache is open source but some features are missing and are only in BigMemory Go and BigMemory Max by Terracota. Some alternatives are Apache Commons JCS, Hazelcast, and Infinispan. – mfulton26 Jun 07 '16 at 13:55
  • 1
    I would consider Hazelcast that has very good integration with JavaEE and is leading the development of the JSR for JCache. – Sergio Jun 08 '16 at 08:45
  • @Sergio Could you please state the benefits of using Hazlecast over Guava or help with any such resource where I can find that? – striker Jul 13 '22 at 05:59
  • 1
    They are not comparable directly. Hazelcast is for distributed caching, meaning many services share the same cache, whereas Guava/Caffeine is a local cache per each service (not shared). It depends on your business requirements. Check the official websites for both technologies to understand them better. – Sergio Jul 13 '22 at 08:03