gnodet opened a new pull request, #26053:
URL: https://github.com/apache/camel/pull/26053

   ## What
   
   Implement atomic `replace()` and `delete(key, expected)` in 
`CassandraKeyValueRepository` using Cassandra lightweight transactions (LWT), 
as flagged by @davsclaus in #25993.
   
   ## Why
   
   `putIfAbsent()` already uses LWT (`INSERT ... IF NOT EXISTS`) for true 
server-side CAS, but `replace()` and `delete(key, expected)` fell back to the 
non-atomic default implementation (read-then-write) from the 
`KeyValueRepository` SPI.
   
   ## How
   
   - **`replace(key, expected, newValue, ttl)`**: Uses `UPDATE ... SET value = 
? WHERE key = ? IF value = ?` (with optional `USING TTL ?`)
   - **`delete(key, expected)`**: Uses `DELETE FROM ... WHERE key = ? IF value 
= ?`
   
   Both methods use the existing `isApplied()` helper to check the LWT result. 
Three new prepared statements are initialized at startup 
(`updateIfValueStatement`, `updateIfValueWithTtlStatement`, 
`deleteIfValueStatement`).
   
   The existing integration tests in `CassandraKeyValueRepositoryIT` already 
cover both operations (testReplaceMatchingOldValue, 
testReplaceNonMatchingOldValue, testReplaceMissingKey, 
testDeleteWithExpectedValue*).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to