Many of the TFNRegistry™ APIs provide a locking mechanism to prevent multiple users changing the same data. The user is required to obtain a unique recVersionId by making a GET API call and returning this value when updating the records. The TFNRegistry will then compare the provided value with the most recent version stored and the update is successfully performed only if they match. The following scenario explains how the optimistic locking works when 2 users, A and B are updating an Area of Service Label (ASL):
- User A retrieves the existing ASL along with the recVersionId with a value: “abc123”.
- User B retrieves the same ASL at the same time and will also receive the same recVersionId with the same value as A “abc123”.
- User B makes necessary changes to the received label and call the update API with recVersionId “abc123”.
- The TFNRegistry successfully processes the requests and generates a new recVersionId “abc124” and invalidates the old value.
- User A tries to update the label with the old recVersionId, the TFNRegistry verifies the provided value and returns an error indicating that the recVersionId does not match.
- User A either can abort his update process or retrieves the ASL again with the new recVersionId and make another update API call.