There are various caching solutions in Java. Among them are Infinispan, EhCache and OSCache.
All of them can also be used autonomously, for example. none of them were created exclusively to work as a Hibernate caching provider.
Functionality between caches is slightly different. Infinispan, for example, provides support for the first class of transactions (this means that the element will not be inserted into the cache if the transaction into which the element was inserted by rollbacks). EhCache has excellent support for a really big process, but with storage heaps for the cache.
OSCache comes with very convenient tags for caching content on JSP pages (but this does not work with JSF).
Most of them are capable of performing a typical spill on a disk subject and have some mechanisms for canceling invalid entries. For example, Infinispan has eviction policies, and they do delete obsolete entries from the cache (memory preservation). OSCache, in turn, never deletes an entry from the cache, but marks it as obsolete. When an entry is available, the caller is notified of a record update (used as an exception, but may be different).
These things are usually a βcacheβ, except for a simple concurrent hash map. If your requirements are modest, do not miss this simple solution. Cache memory can be a little complicated to configure, and for you a map in the application area can be enough.
source share