Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
JSR-107 JCache is a standardized caching API that is Java 6 compatible and introduced in JEE 8. Caffeine provides a local in-memory implementation. The JCache provider is configured using Typesafe's Config library. See the reference.conf for more details. A FactoryCreator may be configured to delegate instantiation to a dependency injection framework.
WARNING: JCache designed ExpiryPolicy to lazily expire entries and rely on a maximum size constraint for eviction. The specification's approach is incompatible with Caffeine's native support, which will eagerly expires entries in O(1) time during periodic maintenance. It is expected by the specification that all uses have an additional size constraint, even though the specification does not support that capability. When using JCache's expiration version, rather than Caffeine's flavor, a size bounding should be used to avoid memory leaks and promptly notify listeners.
Be weary of anonymous caches, which are created using the specification's defaults settings. This means a cache that never expires and stores by value (serialization).
See the Spring documentation.
Prefer using Spring Cache, which includes support for Caffeine as of Spring Framework 4.3 and Spring Boot 1.4.
The JSR provides an integration module that delegates to the JCache provider.
Injector injector = Guice.createInjector(new CacheAnnotationsModule());
The JSR provides an extension that delegates to the JCache provider.