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.
  1. Identify an EIS operation from which you define the MBO create operation that returns all MBO attributes associated with that MBO.
  2. 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.
  3. Define a create operation and select Apply results to the cache as the cache update policy associated with the EIS operation.
  4. Deploy the package.
  5. Synchronize the client to populate the cache.
  6. Create an instance of the MBO on the client device and note the surrogate primary key.
  7. 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.
  8. 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.
  1. Identify an EIS operation from which you define the MBO update operation. The operation may or may not return attribute values.
  2. 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.
  3. Define an update operation and select Apply results to the cache as the cache update policy associated with the EIS operation.
  4. Deploy the package.
  5. Populate the EIS (by whatever means) with a single instance of the MBO and note the attribute values of that MBO.
  6. Synchronize the client to populate the cache.
  7. Update some of the MBO attributes from the client.
  8. Invoke the update operation on the MBO and synchronize.
  9. 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.
  1. Construct a composite relationship between two MBOs.
  2. Identify/construct an EIS operation which deletes the composite (cascading) relationship from the EIS.
  3. 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.
  4. Define a delete operation and select Apply results to the cache as the cache update policy associated with the EIS operation.
  5. Deploy the package.
  6. Populate the EIS (by whatever means) with a single instance of the MBO hierarchy and note the attributes of the MBOs in the hierarchy.
  7. Synchronize the client to populate the cache and provide client access to the MBO hierarchy.
  8. Invoke the delete operation on the root MBO instance and synchronize.
  9. 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.
  1. 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.
  2. Identify/construct an EIS operation which creates an MBO instance and returns nothing.
  3. Define a create operation and unselect all cache update policies associated with the EIS operation.
  4. Deploy the package.
  5. Synchronize the client to populate the cache.
  6. 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.
  7. Invoke the create operation on the MBO and synchronize.
  8. 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.
  1. 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.
  2. Identify/construct an EIS operation which creates an MBO instance and returns no results.
  3. Define a create operation and unselect all cache update policies associated with the EIS operation.
  4. Deploy the package.
  5. Synchronize the client. An initial synchronization populates the cache.
  6. 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.
  7. Invoke the create operation on the MBO and synchronize.
  8. 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.
  1. 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.
  2. Associate the MBO with a Cache Group with a Never On demand cache interval.
  3. 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.
  4. Deploy the package.
  5. Synchronize the client to populate the cache.
  6. Create an instance of the MBO on the client device and note the surrogate primary key.
  7. 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.
  8. Inspect the results on the client device and verify that all the attributes are populated on the client.