Skip to Content
Author's profile photo Wolfgang Sattler

WCEM: Cache usage

In this blog I will give a short overview about the WCEM cache functionality, because this documentation is not yet part of the dev and extension guide of release 2.0 and 3.0.


The WCEM framework provides access to cache functionality, which can be used to store any kind of data.

You can choose between different cache engines. The following implementations are available:

  • Default: CML cache provided by SAP NetWeaver 
  • Custom WCEM implementation (in WCEM standard, used only for internal integration tests) 
  • Mock implementation (in WCEM standard, used only for internal Java unit tests)

Cache Regions and Attributes 

The cache is divided into regions. Each region represents an individual cache, and the region name is used to distinguish between caches. If you need your own cache, you have to add a new region, together with attributes. These attributes define how the cache handles objects that are cached in the region (be aware that not all attributes are supported in each implementation).

The following attributes define the eviction policy within a region (only supported by the CML implementation): 

  • evictionCountStart (Default value: 750) 
  • evictionCountUpperLimit (Default value: 950) 
  • evictionCountCriticalLimit (Default value: 1000)


  <region name="myRegion" countStart="750" countUpper="950" countCritical="1000">  

This means that the eviction of the objects starts when there are 750 objects in the cache region. At 950 objects, the eviction policy starts evicting an object at each put. At 1000 objects, the critical size of the cache is reached and the benefit of the cache is not clear. Idle time and time-to-live (TTL) are explained above.

At this point in time we don’t support time dependent cache entries.

Defining Cache Regions 

The configuration of a cache region can be performed using the cache-config.xml file. Cache regions, which are declared in the cache-config.xml file, are initialized when the application is started by the framework.

Example for defining cache regions within cache-config.xml:

          <region name="JCO" loaderClassName=""
                     descr="Used to cache SAP Java Connector calls to the SAP system"
                     countStart="750" countUpper="950" countCritical="1000" /> 
         <region name="UICOMP" descr="Used to cache configuration data and other settings for ui components" 
                     countStart="750" countUpper="950" countCritical="1000"

Accessing Cache Regions 

The access to the cache is enabled by using a cache access object (CacheAccess). You can get access to your cache region by using the singleton CacheProvider (see example below). The access object provides methods to add, retrieve, invalidate, or remove objects from the cache.

Example: Getting access to region ‘CacheRegion’

  ...  // Get access to cache region 'CacheRegion'  
CacheAccess access = CacheProvider.getInstance().getCacheAccess("CacheRegion");   

// Put object in to cache 
String testKey = "key1"
Object testPut = new Object(); 
access.put(testKey, testPut);  ...   
// Get object from cache 
Object getObject = access.get("key1");  ... 

Defining/Implementing Cache Loader Classes 

Additionally, an abstract class CacheLoader is available, which can be used to create cached objects. This class can be extended to write a custom cache loader. The class JCoFunctionLoader is available as a cache loader for JCo functions.


 CacheAccess cacheAccess = null
try {
   cacheAccess = CacheProvider.getInstance().getCacheAccess(CACHE_REGION_NAME);

catch (WCFCacheException ex) { 
   / / region not available \-> standard execute 

JCO.Function cachedFunc = (JCO.Function) cacheAccess.get(key.toString(), 
new JCoFunctionLoader.JCoFunctionAttr(client, func)); 

Cache Registration 

Each cache-config file has to be maintained in the metadata.xml file.

<config-file namespace=“sap” part=“bo” type=“cache-config”>cache-config.xml</config-file>

Place the cache-config.xml file into the path src\<your namespace>\<your module>\bo\cache-config.xml in your module BO part.

The cache-config.xml file should contain only the definition of the cache region that your own module uses. The cache-config file from other modules, including the system module, will be merged together.

Further information can be found in the Configuration Management documentation.

Enhanced Features

Changing the Cache Implementation

To determine which implementation is used, a parameter is added to the initialization tag within file bootstrap-config.xml for class “”:

 <initialization name="CacheInitHandler" className="">  
    <param name="cacheEngine" value=""/> 

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hello Wolfgang,

      I have access to this API documentation? I already checked on the WCEM 3.0 Operation Guide, Master Guide, Developer Guide and I haven't found any API doc.