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

   ## Summary
   
   _Claude Code on behalf of gnodet_
   
   Refines the `KeyValueRepository` SPI introduced in PR #25863 to simplify 
implementation across persistent backends (JDBC, JPA, Cassandra, Kafka — coming 
in a follow-up PR).
   
   ### Changes
   
   - **TTL type: `Duration` → `long ttlMillis`** — All four backends work in 
millis internally. `Duration` added conversion boilerplate (`toMillis()`, null 
checks) for no practical benefit since no implementation uses sub-millisecond 
or calendar-aware TTL. This change simplifies every `put`/`putIfAbsent` 
implementation.
   
   - **Convenience defaults: `put(key, value)` and `putIfAbsent(key, value)`** 
— Most usage sites don't need TTL (idempotent consumer stores `Boolean.TRUE`, 
aggregation stores `DefaultExchangeHolder`). The new defaults delegate to the 
TTL variants with `0`, eliminating the need for callers to pass a dummy value.
   
   - **Remove `replace()` and `delete(key, expectedValue)` CAS methods** — No 
current or planned implementation overrides these with a real atomic CAS 
operation; the default implementations were non-atomic and misleading. If CAS 
semantics are needed later, they can be re-added with proper atomicity 
requirements.
   
   - **Extract `KeyValueRepositoryHelper`** — Shared 
serialization/deserialization utility (`byte[]`, `ByteBuffer`, offset variants) 
that eliminates ~143 lines of duplicated try/catch boilerplate across the 4 
persistent implementations.
   
   - **Update adapters and tests** — `KeyValueIdempotentRepository` and 
`KeyValueAggregationRepository` now use the convenience methods. All existing 
tests updated from `Duration`/`null` to `long`/`0`.
   
   ### Test plan
   
   - [x] `MemoryKeyValueRepositoryTest` — 19 tests pass
   - [x] `KeyValueIdempotentRepositoryTest` — 14 tests pass
   - [x] `KeyValueAggregationRepositoryTest` — 12 tests pass
   
   ### Follow-up
   
   The JDBC, JPA, Cassandra, and Kafka `KeyValueRepository` implementations 
(with container tests) will be submitted as a separate PR rebased on this one.
   
   🤖 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]

Reply via email to