What are the prons and cons between using “static Hashmap store object” and apache java cache system for web based enterprise apps? Which one is best for performance and reduce heap memory problem
ex:
Map store=ApplicationCtx.getApplicationParameterMap();
UserObj obj=store.get('user');
VS
UserObj obj = JCS.getInstance("user");
If you want the best of both worlds, you might consider using a synchronized LinkedHashMap which can be used as an LRU cache (a basic eviction policy) and is thread safe.
A HashMap is simpler and faster, it doesn’t do very much and is not thread safe. (Which is why it is the fastest)
Most Caching systems are more sophisticated which means there will be a small overhead. e.g. they are thread safe (which I am sure you will need) and support eviction policies (which you also indicate you will need)
In short, the first one is fastest but probably won’t do what you need. The second will help you manage how much memory you use.