Avoiding Write Clashes with Conditional Updates¶
If your application supports a user interface that enables writing to CM-Well, it's possible for several users to request updates to the same infoton at the same time. This can potentially result in one user's updates silently overwriting another user's updates.
To avoid this situation, you can use the conditional update feature. To use the feature, you send the UUID of the infoton you want to update, and if the UUID has changed since the time you last read it, you can show a warning or error to your user.
See Using Conditional Updates to learn more about conditional update syntax.
If your application provides a UI for updating CM-Well, we recommend implementing the following application logic:
- Read the relevant data from CM-Well before displaying it to the user.
- Periodically refresh the displayed data.
- Refresh the data again when entering editing mode.
- When attempting an update, use the conditional update feature (send the previous UUID for verification).
- If you receive a status indicating that the infoton has changed since your last read, handle according to your requirements (for instance, fail the update or display a warning).