cancel
Showing results for 
Search instead for 
Did you mean: 

Creating new cache instance

Former Member
0 Kudos

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?

View Entire Topic
Former Member
0 Kudos

Hi!

Mandatory cache properties are:

CacheFactory.CFG_CACHE_CLASS_KEY, e.g. ICache.DEFAULT_CACHE_CLASS (for memory caches)

CacheFactory.CFG_CACHE_TYPE_KEY, e.g. CacheFactory.CFG_MEMORY_KEY (for memory caches)

CacheFactory.CFG_SINGLETON_KEY, e.g. ICache.DEFAULT_SINGLETON (true)

CacheFactory.CFG_STORAGE_CLASS_KEY is needed only for persistent caches and will contain

a Java class that stores the content in the filesystem.

bye, Dirk