java - Ehcache with tomcat simple example -


i want include ehcache in java web application hosted in tomcat. want check cache key , if key exists retrieve it, if not add cache later retrieval (just memcached usage scenario).

i searched documentation , couldn't find useful information on how implement simple example. found out need put ehcache-core.jar , slf4j*.jar in classpath along ehcache.xml. ? can see ehcache cache object in examples - should instantiate in order accessible servlets / jsps ? also, can recommend simple cache configuration put in ehcache.xml ? default

     <defaultcache            maxentrieslocalheap="0"            eternal="false"            timetoidleseconds="1200"            timetoliveseconds="1200">     </defaultcache> 

ok ?

do like

cachemanager.getinstance().addcache("xyz"); // creates cache called xyz.  cache xyz = cachemanager.getinstance().getcache("xyz");  xyz.put(new element("key", new person())); element e = xyz.get("key"); person p = (person) e.getobjectvalue(); 

there better elegant ways play cache. refer http://ehcache.org/documentation/code-samples. check spring integration it.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -