Updating selfpopulatingcache example
Next we want to enable Terracotta clustering for the cache named sample Terracotta Cache. We are evaluating the use of EHCache in our project. If I put a 500,000 entries into a Hash Map, the memory consumed is about 114MB. Code to use a query cache follows:public List get Street Types(final Country country) throws Hibernate Exception The Cacheable(true) line caches the query. Street Types") line sets the name of the Query Cache.Alex Miller has a good article on the query cache here.The name of the cache in is then the name given in that method.The name can be whatever you want, but by convention you should use "query." followed by a descriptive name. 使用缓存查询For example, let's say we have a common query running against the Country Domain. Simply put: you should have the Memory Store large enough that it covers the bulk of the items you want cached.In general, keeping an eye on cache hits and miss will tell you a lot about the cache effectiveness.
Dynamic in this case refers to caches that are added programmatically or using the Terracotta Developer Console while the Cache Manager is running.
Ehcache won't reduce the amount of garbage produced, in fact because it is doing much more work, it could produce much, much more (esp.
The bottom line is Eh Cahe is using the same amount of memory as a Hash Map!
The other thing to keep an eye on is how much the cache has no size limit – in theory, it could fill up your entire file system, particularly if you have your objects marked as eternal (which means they will never expire). Let’s go for a simple example: I have an Order object, which contains 3 Order Items.
Order Item, in turn, has a reference back to Order.
Search for updating selfpopulatingcache example:
We tested by using a simple hash Map and since the size could overshoot the heap size we wanted to ensure that we could control that.. If I use EHCache and limit the number of entries in the heap to 10 and local disk to 500000 it consumes 98MB. I was thinking that I should be able to see only a small amount of heap used since only 10 entries are in the heap.