Removing a key-value pair from the global cache by using a Mapping node

You can use a Mapping node to remove a key-value pair from a map in an embedded cache or a WebSphere® eXtreme Scale grid.

Before you begin

You must complete the following task:
  • Create a graphical data map by using the Graphical Data Mapping editor. For information, see Creating a message map.

About this task

You can use a Cache Remove transform in a Mapping node to remove data from the global cache.

Interactions with the global cache happen outside the message flow transaction, and are committed immediately. If an error occurs downstream of the node that interacts with the global cache, the cache interactions are not rolled back.

To configure a graphical data map to remove data from the global cache, complete the following steps:

Procedure

  1. Open the graphical data map in the Graphical Data Mapping editor.
  2. In the toolbar, click the Cache Remove icon (icon) to add a Cache Remove transform to the canvas.
  3. Provide values for the parameters in the Cache Remove transform by completing one of the following steps:
    • Map the input elements to the Cache Remove transform.
      Note: You can also select the elements before you click the Cache Remove icon. The elements that you select are then automatically mapped to the Cache Remove transform.
    • Identify fixed values or user-defined properties to assign to the parameters.

    For example, in the following image, the Key element is mapped to the Cache Remove transform.

    The image is described in the surrounding text.

  4. Double-click the Cache Remove transform to edit the nested map.
    Note: To edit the nested map, you can also perform any of the following operations:
    • Click the Cache Remove link in the Cache Remove transform.
    • Click the arrow in the upper right corner of the Cache Remove transform.
    • Place the mouse over the Cache Remove transform, and click Click here in the pop-up window.

    The output elements of the nested map are the predefined parameters that are required to perform the Cache Remove transform. If you mapped elements to the Cache Remove transform, the elements are displayed as input elements in the nested map.

  5. Required: Provide a value for the Key parameter of the Cache Remove transform by using one of the following options:
    Note: The Cache Remove transform is marked with an error until a value is provided for the Key parameter.
    • Map an element from the input tree.
    • Set a fixed value for the key by right-clicking the Key parameter in the Cache Remove transform, clicking Add Assign, and adding the required value in the Properties pane. For more information about the Assign transform, see Assign.
    • Set a value for the key by using a user-defined property; see Accessing user-defined properties from a Mapping node.

    For example, in the following image, the content for the Key parameter is provided by mapping an element that is named Key from the input tree.

    The image is described in the surrounding text.

  6. Optional: Map or assign values to the MapName, or CacheName and MapName parameters; for information about valid values for these parameters, see Cache Remove.
  7. Optional: Right-click the Cache Remove transform and select Cache > Return to implement a nested mapping that is called if the Cache Remove transform completes successfully.
    Note: You can also add a Cache Return transform by placing the mouse over the Cache Remove transform and selecting the Cache Return icon (icon).

    The nested mapping in the Cache Remove transform provides an input element (Value) for the Cache Return transform. The input element provides the value of the global cache entry that was removed.

    The predefined Value input element in the Cache Return nested mapping has a default schema type of xs:anySimpleType. If you know the type of the Java™ object in the cache, you can map directly to a target element that has the schema type that matches the Java Object type; see Schema types that are returned for each supported Java Object type.

    If the entry in the cache might have one of several Java Object types, you can apply mapping casts to the predefined Value input element. For more information, see Cache Return.

    At run time, if no entry exists in the global cache with the provided key, the Cache Remove transform still completes successfully and invokes the Cache Return transform but the Value element does not exist.

  8. Optional: Right-click the Cache Remove transform and select Cache > Failure to implement a nested mapping that is called if the Cache Remove transform fails. For more information, see Handling global cache exceptions in a graphical data map.
    Note: You can also add a Cache Failure transform by placing the mouse over the Cache Remove transform and selecting the Cache Failure icon (icon).
  9. Save the graphical data map.

Results

You removed a key-value pair from the global cache.

What to do next

Complete the following tasks:

For more information about the Cache Remove transform, see Cache Remove.