I'm a Lead engineer at Terracotta, Software AG. I have 10+ years of experience with Java, but I also speak other languages, C, C++, Javascript, Coffeescript, PHP, Perl... See my blog to know about my different personal projects! Aurelien is a DZone MVB and is not an employee of DZone and has posted 17 posts at DZone. You can read more from them at their website. View Full User Profile

Ehcache Size Configuration

05.28.2012
| 11110 views |
  • submit to reddit

Since Ehcache 2.5, you’ve got Automatic Resource Control (ARC), which help you to easily tune your cache.

When you think that software is constantly changing, let’s say you have a class that takes 1Kb when instantiated, then you put 1000000 elements in a cache, it takes 1Gb. After a few releases, the class has been modified, it has more fields, and it takes now 2Kb when instantiated, the exact same cache definition will take 2Gb…

ARC helps you to define a cache by memory size. In this example you say you want your cache to use 1Gb of heap memory, it will first hold 1M elements, then 500000… Your tuning is automatically handled…

In case you want to have a look at ARC vs count-based config, here is a summary of options you can use:

Standalone – Cache Configuration

  Count-based Count-based – legacy pre-2.5 Size-based (ARC)
Heap maxEntriesLocalHeap maxElementsInMemory (deprecated) maxBytesLocalHeap
Off heap maxMemoryOffHeap maxMemoryOffHeap maxBytesLocalOffHeap
Disk maxEntriesLocalDisk maxElementsOnDisk maxBytesLocalDisk

Clustered – Cache Configuration

  Count-based Count-based – legacy pre-2.5 Size-based (ARC)
Heap maxEntriesLocalHeap maxElementsInMemory (deprecated) maxBytesLocalHeap
Off heap maxMemoryOffHeap maxMemoryOffHeap maxBytesLocalOffHeap
Disk NA maxElementsOnDisk NA

more info on Ehcache ARC

Published at DZone with permission of Aurelien Broszniowski, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Daniel Slazer replied on Tue, 2012/06/12 - 12:35pm

Here is a point that , you can keep replying by putting good thought in kind manner but seems that if some one like me ask something and in first attempt of reply the person like you without going to understand the point behind the question , simply writes some rude statement. did you directly started walking after your birth or it took some time for you to walk ?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.