-
Hello. The manual provided by Github wiki is provided as follows Cache<Key, Graph> cache = Caffeine.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
.maximumSize(10_000)
.build();
// Lookup an entry, or null if not found
Graph graph = cache.getIfPresent(key);
// Lookup and compute an entry if absent, or null if not computable
graph = cache.get(key, k -> createExpensiveGraph(key));
// Insert or update an entry
cache.put(key, graph);
// Remove an entry
cache.invalidate(key); I'd like to open a Caffeine object created by this newBuilder. I understood that BoundLocalManualCache/UnboundLocalManualCache was created and returned, and that these objects were created using the methodHandle provided by java, but I couldn't find the methodHandle combined with which creator and which Caffeine cache implementation was used. If you can help me understand the internal behavior, I think it will help me understand. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The implementations are private to the package. The unit tests unwrap to inspect internals, such as The build uses a code generator for the concrete classes, which the method handle loads. This is to avoid memory waste to minimize field allocations, as only a few types might be used in a given application. The generated code is part of the sources jar (so your IDE should find it) or can be created by running |
Beta Was this translation helpful? Give feedback.
The implementations are private to the package. The unit tests unwrap to inspect internals, such as
caffeine/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedLocalCacheTest.java
Lines 2808 to 2810 in 72ec19e
The build uses a code generator for the concrete classes, which the method handle loads. This is to avoid memory waste to minimize field allocations, as only a few types might be used in a given application. The generated code is part of the sources jar (so your IDE should find it) or can be created by running
grad…