gnodet opened a new pull request, #25863: URL: https://github.com/apache/camel/pull/25863
_Claude Code on behalf of @gnodet_ ## Summary Adds compare-and-swap (CAS) operations to the `KeyValueRepository` SPI as default methods, enabling optimistic-locking patterns on top of the unified key-value abstraction. ### New methods on `KeyValueRepository` | Method | Description | |--------|-------------| | `replace(key, expectedOld, newValue, ttlMillis)` → `boolean` | CAS put — succeeds only if the current value matches `expectedOld` | | `delete(key, expectedValue)` → `boolean` | CAS delete — succeeds only if the current value matches `expectedValue` | Both are `default` methods with non-atomic fallback implementations (read-compare-write). Backends that support native CAS can override for atomicity. ### `MemoryKeyValueRepository` — atomic override Uses `ConcurrentHashMap.computeIfPresent()` for lock-free atomicity. ### Motivation These methods are the building blocks needed by `OptimisticLockingAggregationRepository` and similar concurrency patterns. Splitting them out from #25816 so that all technology-specific `KeyValueRepository` PRs (#25816, #25818) can benefit from them. ### Tests 7 new CAS tests in `MemoryKeyValueRepositoryTest`: - `testReplaceMatchingValue`, `testReplaceNonMatchingValue`, `testReplaceMissingKey`, `testReplaceWithTtl` - `testDeleteWithMatchingValue`, `testDeleteWithNonMatchingValue`, `testDeleteWithMissingKey` 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
