Cache Update Policy Examples

These scenarios illustrate how to use cache update policies and mobile business object (MBO) operations to combine and merge in-memory MBO attributes and enterprise information system (EIS) results and apply them to the Unwired Server cache (CDB).

Insert a row into the cache

The merged results represent a new row that is inserted into the cache. Multiple row insertions are not supported.

Identify an EIS operation from which you define the MBO create operation that returns all MBO attributes associated with that MBO.

Associate the MBO with a Cache Group with an On demand policy and a very large cache interval. This ensures that the operation results and not the cache policy refreshes the cache.

Define a create operation and select Apply results to the cache as the cache update policy associated with the EIS operation.

Deploy the package.

Synchronize the client to populate the cache.

Create an instance of the MBO on the client device and note the surrogate primary key.

Invoke the create operation on the MBO and synchronize. A row with the surrogate primary key that contains all the MBO attributes is created in the cache.

Inspect the results on the client device and verify that all the attributes are populated.

Update the cache

The merged results represent a change to an existing cached row. Multiple row updates are not supported.

Identify an EIS operation from which you define the MBO update operation. The operation may or may not return attribute values.

Associate the MBO with a Cache Group with an On demand policy and a very large cache interval. This ensures that the operation results and not the cache policy refreshes the cache.

Define an update operation and select Apply results to the cache as the cache update policy associated with the EIS operation.

Deploy the package.

Populate the EIS (by whatever means) with a single instance of the MBO and note the attribute values of that MBO.

Synchronize the client to populate the cache.

Update some of the MBO attributes from the client.

Invoke the update operation on the MBO and synchronize.

Inspect the results on the client device and verify that the attributes have been updated as expected.

Delete a row from the cache

The in-memory attributes provide the surrogate keys for the row(s) that are marked for deletion from the cache. To support relationship composite deletes, multiple rows can be deleted. The EIS results are not required since the surrogate key provided by the in-memory attributes is sufficient to identify the rows.

Construct a composite relationship between two MBOs.

Identify/construct an EIS operation which deletes the composite (cascading) relationship from the EIS.

Associate the MBO with a Cache Group with an On demand policy and a very large cache interval. This ensures that the operation results and not the cache policy refreshes the cache.

Define a delete operation and select Apply results to the cache as the cache update policy associated with the EIS operation.

Deploy the package.

Populate the EIS (by whatever means) with a single instance of the MBO hierarchy and note the attributes of the MBOs in the hierarchy.

Synchronize the client to populate the cache and provide client access to the MBO hierarchy.

Invoke the delete operation on the root MBO instance and synchronize.

Inspect and confirm that all the MBO instances associated with the hierarchy have been deleted on the client device.

Notify when the cache changes with a primary key (no cache update policy)

The in-memory attributes provide sufficient information to establish the primaryKey-to-surrogatePrimaryKey linking, creating a row in the cache and marking it as "create pending" until an On demand or Scheduled refresh occurs.

Create an MBO and associate it with a cache group that has a default cache policy set to a zero On demand cache interval. When set to zero, each device-initiated synchronization refreshes the entire cache prior to synchronization.

Identify/construct an EIS operation which creates an MBO instance and returns nothing.

Define a create operation and unselect all cache update policies associated with the EIS operation.

Deploy the package.

Synchronize the client to populate the cache.

Create an instance of the MBO on the client device and take note of the surrogate primary key. Populate the primary key attributes of the MBO.

Invoke the create operation on the MBO and synchronize.

Inspect the results on the client device and verify that all the attributes are populated.

Notify when the cache changes without a primary key (no cache update policy)

Since the in-memory attributes are not sufficient to establish a primaryKey-to-surrogatePrimaryKey linking, a row is created in the cache and marked as logically deleted.

Create an MBO and associate it with a cache group that has a default cache policy set to a zero On demand cache interval. When set to zero, each device-initiated synchronization refreshes the entire cache prior to synchronization.

Identify/construct an EIS operation which creates an MBO instance and returns no results.

Define a create operation and unselect all cache update policies associated with the EIS operation.

Deploy the package.

Synchronize the client. An initial synchronization populates the cache.

Create an instance of the MBO on the client device and take note of the surrogate primary key. Do not populate the primary key attributes of the MBO.

Invoke the create operation on the MBO and synchronize.

Inspect the results on the client device and verify that the original instance has been deleted and has been replaced with a new instance with a new surrogate primary key.

Combining cache update policies

In some cases the results returned from the EIS operation are sufficient to establish the surrogatePrimaryKey-to-primaryKey linking, but not sufficient to fully populate the MBO in the cache. In these cases combining the apply results and the invalidate the cache cache update policy settings in a single operation can achieve the desired results.

Identify/construct an EIS operation which creates an MBO instance and returns all the MBO attributes (not including surrogate key fields) associated with that instance, except for one non-primary-key attribute.

Associate the MBO with a Cache Group with a Never On demand cache interval.

Define a create operation that uses both the Apply results to the cache and Invalidate the cache cache update policies and associate it with the EIS operation identified above.

Deploy the package.

Synchronize the client to populate the cache.

Create an instance of the MBO on the client device and note the surrogate primary key.

Invoke the create operation on the MBO and synchronize. A row with the surrogate primary key noted previously is created in the CDB that contains all the MBO attributes including the one which was not returned from the create operation.

Inspect the results on the client device and verify that all the attributes are populated on the client.