Skip to Content
0
Former Member
Jan 10, 2006 at 09:43 AM

Creating new cache instance

21 Views

I want to create a new KM cache which is not preconfigured.

According to https://media.sdn.sap.com/javadocs/NW04/SP12/km/com/sapportals/wcm/util/cache/CacheFactory.html

this should be possible with the getCache(String cacheID, Properties properties) method.

I tried the following code:

String cacheID = CacheFactory.getUniqueCacheID();

Properties cacheProp = new Properties(); cacheProp.setProperty(CacheFactory.CFG_MAX_CACHE_SIZE_KEY, "1000000"); cacheProp.setProperty(CacheFactory.CFG_CAPACITY_KEY, "500"); cacheProp.setProperty(CacheFactory.CFG_MAX_ENTRY_SIZE_KEY, "500");

cacheProp.setProperty(CacheFactory.CFG_AVERAGE_ENTRY_SIZE_KEY, "20000"); cacheProp.setProperty(CacheFactory.CFG_SINGLETON_KEY, "true");

cacheProp.setProperty(CacheFactory.CFG_DEFAULT_TIME_TO_LIVE_KEY, "0"); cacheProp.setProperty(CacheFactory.CFG_STORAGE_CLASS_KEY,CacheFactory.CFG_MEMORY_KEY);

try {

CacheFactory cacheFac = CacheFactory.getInstance();

cache = cacheFac.getCache(cacheID, cacheProp);

} catch (Exception e) {

e.printStackTrace();

}

Unfortunately I always get an exception. Is where any other property what I have to set?