java - EHCache configuration in WebApplication -
i have written below code getting cachemanager object
public class ehcacheutil implements serializable{ /** * */ private static final long serialversionuid = 1l; public static cachemanager cachemgr = null; private static ehcache getcache(string cachename) throws exception{ if(cachemgr == null){ file file = new file("f:\\projectworkspace\\src\\java\\ehcache.xml"); // use environment or vm variable cachemgr = cachemanager.create(new fileinputstream(file)); system.out.println("cachemgr.cacheexists(cachename)"+cachemgr.cacheexists(cachename)); } ehcache cache = null; if(cachemgr!=null){ //cache = cachemgr.addcacheifabsent(name); cache = cachemgr.getehcache(cachename); } return cache; }
ehcache.xml
<?xml version="1.0" encoding="utf-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="http://ehcache.sf.net/ehcache.xsd"> <diskstore path="g:\ehcachetempmemory" /> <defaultcache maxelementsinmemory="10000" eternal="false" overflowtodisk="true" timetoidleseconds="10" timetoliveseconds="20" diskpersistent="true" /> <cache name="mycache1" maxelementsinmemory="500000" maxelementsondisk="500000" eternal="false" overflowtodisk="true" timetoidleseconds="864000" timetoliveseconds="8640000" diskpersistent="true" diskspoolbuffersizemb="20" diskexpirythreadintervalseconds="8640000" memorystoreevictionpolicy="lfu" /> </ehcache>
sop printing true stand alone application not web application. can 1 explain issue?
Comments
Post a Comment