thomas-gantenbein-tga commented on code in PR #22311:
URL: https://github.com/apache/camel/pull/22311#discussion_r3018024176


##########
core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/MemoryIdempotentRepository.java:
##########
@@ -77,6 +79,21 @@ public static IdempotentRepository 
memoryIdempotentRepository(int cacheSize) {
         return answer;
     }
 
+    /**
+     * Creates a new memory based repository using a {@link 
java.util.LinkedHashMap} as its store, with the given
+     * maximum capacity. When a new entry is added and the store has reached 
its maximum capacity, the oldest entry is
+     * removed.
+     */
+    public static IdempotentRepository 
memoryIdempotentRepositoryInsertionOrder(int cacheSize) {
+        LinkedHashMap<String, Object> map = new LinkedHashMap<>() {
+            @Override
+            protected boolean removeEldestEntry(Entry<String, Object> eldest) {
+                return size() > cacheSize;
+            }
+        };

Review Comment:
   Thanks. I guess I am not supposed to change the name of that `cacheSize` to 
`maxCacheSize`, since that's annotated with `@Metadata`? Or am I? I'd find that 
clearer. I find it confusing that `getCacheSize()` and `setCacheSize(int 
cacheSize)` are not targeting the same thing.
   
   I'm also calling `ServiceHelper.startService(answer);`, since that's also 
what's done in ` public static IdempotentRepository 
memoryIdempotentRepository(int cacheSize)`, but I don't have a clue what the 
benefit of that is.



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