Skip to content

Optimistic Concurrency Control

Overview

Optimistic concurrency control ensures that operations on resources are performed only when specific conditions are met. This is achieved using conditional request headers, which allow clients to validate the state of a resource (folders/files) before executing an operation.

Conditional Request Header Support

The following headers are used to implement optimistic concurrency control:

  • If-Match:
    Executes the request only if the provided value matches the current state of the resource.
    Example: Use this header to ensure that delete operation is performed only if the resource has not been modified since the last known state.

  • If-None-Match:
    Executes the request only if the provided value does not match the current state of the resource.
    Example: Use this header to ensure that a resource is created only if it does not already exist.

Usage Scenarios

  1. Name Validation:
    Ensures that a resource with same name either exists (If-Match) or does not exist (If-None-Match) in the target before proceeding with an operation.

  2. Version Validation:
    Validates the version of a resource to ensure that operations are performed only if the resource latest version matches (If-Match) or does not match (If-None-Match) a specified version, depending on the header used.

These headers are particularly useful in scenarios where multiple clients may attempt to modify the same resource concurrently, helping to prevent conflicts and ensure data integrity.

For a detailed reference on the supported headers for different operations, refer to the corresponding operation in the API specification: API Specification.