Third-Party Caching Software - What Do They Provide?

Why do you want to use a cached out-of-box product like ehcache or memcached?

Will there be a simple hash file? I understand that this is a naive question, but I would like to get some answers about when a simple hashmap will be enough and a third-party caching solution will be redundant.

+6
java caching
source share
2 answers

Some things that Ehcache can give you are that you have to manage yourself using a HashMap.

Eviction Policy. If your data never grows, then you need not worry. But if you want to prevent a memory leak that will ultimately break your application, you need an eviction policy. With ehcache, you can set the time for live and the time for idle items in your cache.

Clustered caching with terracotta. If you have more than one tomcat to switch to another resource / scalability, you can link Ehcache to the Terracotta cluster so that all instances can see the same data, if necessary.

Transparent disk overflow - whether on a tomcat server or on a terracotta cluster. When data does not fit into the heap.

Inactive heap storage. New technologies, such as BigMemory, mean that you have access to a much larger cache in memory without GC overhead.

Concurrency. Ehcache can use ConcurrentDistributedMap to provide optimal performance in a clustered configuration.

This is just the tip of the iceberg.

+4
source share

as Tom said, demands say everything. If all you need is a place to enter your data using key-value pairs, make a hash map.

But if you need overflow capabilities (writing to disk when the card is β€œfull”), expiration (delete when the recording was not β€œtouched” after a while), cluster caches, redundant caches, you back off not inventing the wheel paradigm and use third-party caching solution.

I have been using ehcache for almost 3 years now. I use only part of the full feature set, but the ones I do work just fine.

+1
source share

All Articles