gnodet commented on PR #22311:
URL: https://github.com/apache/camel/pull/22311#issuecomment-4222324071

   `LinkedHashMap` is not concurrent, but it doesn't need to be in this context 
— all access in `MemoryIdempotentRepository` is already guarded by a 
`ReentrantLock` (`cacheAndStoreLock`). Every `add()`, `contains()`, `remove()`, 
and `clear()` acquires the lock before touching the map. So the underlying map 
only needs to be a plain `Map`, not a concurrent one.
   
   The current `SimpleLRUCache` with its internal `ConcurrentHashMap` is 
actually overkill here — you get double-locking (repository lock + CHM segment 
locks) for no benefit.
   
   Caffeine would be the right choice if we needed a standalone concurrent LRU 
cache without external synchronization, but for the in-progress repository 
pattern (add, process, remove — no LRU access-order reordering needed), a 
locked `LinkedHashMap` with `removeEldestEntry` is the simplest correct 
solution.
   
   I agree with @davsclaus's suggestion to just make 
`MemoryIdempotentRepository` use `LinkedHashMap` by default.
   
   _Claude Code on behalf of Guillaume Nodet_


-- 
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