ben-manes commented on PR #10157: URL: https://github.com/apache/camel/pull/10157#issuecomment-1560276830
Second Chance (Clock) is very easy to implement to give LRU like hit rates, high read concurrency, and is a good fit for small custom caches. It is basically a FIFO with a mark bit that is set on read. On a write a global lock is acquired, the FIFO is scanned resetting the mark bit, and the first unset entry is chosen for eviction. This means the worst case is O(n), which is fine for a cache of a few thousand entries. As reads are the common case, writes on this lock for a small amount of work is acceptable. When brainstorming approaches for ConcurrentLinkedHashMap (Guava/Caffeine predecessor), that was my original approach that triggered my interest when solving some work performance problems. I had to release that as a [pre-1.0 beta](https://github.com/ben-manes/concurrentlinkedhashmap/wiki/Changelog#version-00-production) to mitigate people from using my unstable concurrent lru alpha code, so you can see review that as a [reference](https://github.com/ben-manes/concurrentlinkedhashmap/blob/cc3e11603e8a91185c1748633be2c703e218219e/src/test/java/com/googlecode/concurrentlinkedhashmap/caches/ProductionMap.java#L64) and a [basic analysis](https://github.com/ben-manes/concurrentlinkedhashmap/blob/wiki/Efficiency.md). -- 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: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org