Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

third-party Caching software- what do they provide?

Tags:

java

caching

Why would one want to use an out of the box caching product like ehcache or memcached ?

Wont a simple hashmap do ? I understand this is a naive question but I would like to see some answers about when a simple hashmap will suffice and a thirdparty caching solution is overkill.

like image 509
mafalda Avatar asked Feb 08 '11 00:02

mafalda


1 Answers

Some things Ehcache can give you, that you would have to manage yourself with a HashMap.

An eviction policy. If your data never grows, then no need to worry. But if you want to prevent a memory leak eventually breaking your app, then you need an eviction policy. With ehcache, you can configure the time to live, and time to idle of elements in your cache.

Clustered caching with Terracotta. If you have more than one tomcat for failover / scalability, then you can link Ehcache up to a Terracotta cluster, so that all instances can see the same data if needed.

Transparent disk overflow - be this on the tomcat server, or the terracotta cluster. When data doesn't fit into heap.

Off heap storage. New technologies such as BigMemory mean you have access to a much larger in-memory cache without GC overheads.

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

This is just the tip of the iceberg.

like image 132
toolkit Avatar answered Nov 06 '22 23:11

toolkit