createOrUpdateProperty
Creates a new property or updates it if it already exists (upsert operation).
This is a convenience operation that:
Adds the property if it doesn't exist
Updates the property if it already exists
Race Condition Warning: This operation is NOT atomic. Between the existence check and the create/update operation, another coroutine could:
Create the property (causing a duplicate creation attempt)
Delete the property (causing an update on a non-existent property)
For truly atomic upsert behavior, implementations should provide a native upsert operation.
Example:
// Create or update a property
val timeout = Property(name = "timeout", value = 5000)
store.createOrUpdateProperty(timeout)
// Safe to call multiple times
store.createOrUpdateProperty(Property(name = "maxRetries", value = 3))
store.createOrUpdateProperty(Property(name = "maxRetries", value = 5)) // Updates to 5Content copied to clipboard
Parameters
T
the type of the property value
property
the property to create or update