IBM Integration Bus, Version 9.0.0.8 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

See information about the latest product version

Removing data from the global cache

Specify when data is removed automatically from the global cache.

Before you start:

Create a message flow that contains a JavaCompute node, and create a Java™ file for that node. For detailed instructions, see Accessing the global cache with a JavaCompute node.

When you get an MbGlobalMap object, you can specify how long the data remains in the global cache before it is removed automatically. This time is known as the time to live and is counted from when that map entry is last updated. The value applies to all cache entries that are created by using that MbGlobalMap object in that instance of the message flow. Data that is already in the map that you specify, or that is created by another MbGlobalMap object, is not affected by the time to live value.

By default, the time to live is set to zero so that the data is never removed. To set a specific time to live, create a session policy, which you can reference from the MbGlobalMap object.

You can specify the time to live value in two ways. The following examples both demonstrate how to set a time to live of 60 seconds for cache entries in the map "myMap".
Example 1
MbGlobalMap myMap = MbGlobalMap.getGlobalMap("myMap", new MbGlobalMapSessionPolicy(60));
Example 2
MbGlobalMapSessionPolicy sessionPol = new MbGlobalMapSessionPolicy(60);
MbGlobalMap myMap = MbGlobalMap.getGlobalMap("myMap", sessionPol);
Data in the map "myMap" is removed automatically 60 seconds after it is last updated.

You can create multiple MbGlobalMap objects in different flows, integration servers, or brokers, all resolving to the same map in the global cache, but with different time to live values. However, you must structure the code in a specific way when you want to put multiple cache entries, with different time to live values, into the same map in the same message flow.

In the following example, the MbGlobalMap objects are all created before the put statements are made. All three MbGlobalMap objects resolve to the same underlying map. The time to live value of each subsequent MbGlobalMap object replaces the value that was set for the previous object. Therefore, for each put statement, data is removed after 20 seconds.
MbGlobalMap m1 = MbGlobalMap.getGlobalMap("myMap", new MbGlobalMapSessionPolicy(60));
MbGlobalMap m2 = MbGlobalMap.getGlobalMap("myMap", new MbGlobalMapSessionPolicy(40));
MbGlobalMap m3 = MbGlobalMap.getGlobalMap("myMap", new MbGlobalMapSessionPolicy(20));
m1.put("k1","v1");
m2.put("k2","v2");
m3.put("k3","v3");
In the following example, each put statement is made directly after the associated MbGlobalMap object is created. Therefore, the cache entry that is made by each put statement assumes a different time to live value.
MbGlobalMap m1 = MbGlobalMap.getGlobalMap("myMap", new MbGlobalMapSessionPolicy(60));
m1.put("k1","v1");
m1 = MbGlobalMap.getGlobalMap("myMap", new MbGlobalMapSessionPolicy(40));
m1.put("k2","v2");
m1 = MbGlobalMap.getGlobalMap("myMap", new MbGlobalMapSessionPolicy(20));
m1.put("k3","v3");

To complete the interaction with the global cache, complete the remaining steps in Accessing the global cache with a JavaCompute node.


bc23801_.htm | Last updated Friday, 21 July 2017