Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any Java caches that can limit memory usage of in-memory cache, not just instance count?

I am looking for a simple in-memory (and in-process) cache for short-term caching of query data (but short-term meaning beyond request/response, i.e. session boundary). EhCache would probably work, but it looks as if it might not offer one thing that I need: limits not on number of objects cached, but (approximate) limit on amount of memory consumed by cached data.

I understand that it is hard to figure out exact memory usage for given object without serialization (which I want to avoid in general case due to its slowness defeats the purpose for my uses), and I am fine with having to provide size estimate myself.

So: is there a simple open source java cache that allows for defining "weight" of cached objects, to limit amount of things cached?

EDIT (Nov 2010): For what it's worth, there is a new project called Java CacheMate that tries to tackle this issue, along with some other improvement ideas (multi-level in-memory in-process caching)

like image 886
StaxMan Avatar asked Mar 27 '09 17:03

StaxMan


1 Answers

EhCache V2.5 currently offers a solution which can cap based on the memory size of the cache. For more details checkout EhCache 2.5 Documentation

like image 200
Snehal Avatar answered Sep 20 '22 04:09

Snehal