Skip to content

JCache zh CN

Ben Manes edited this page Jan 2, 2021 · 4 revisions

JSR-107 JCache是一个在JEE8中引入的与Java6兼容的标准化缓存API。Caffeine提供了JSR-107标准下的一个本地缓存实现。JCache provider通过Typesafe的Config库来进行配置。可以通过查看reference.conf来了解更多细节。FactoryCreator可以配置在依赖注入框架中进行实例管理。

注解支持

匿名缓存将会根据规范的默认配置而创建。这意味着缓存里的数据永远不会过期并且根据缓存的值value所保存(序列化)。

Spring

查看Spring文档.

推荐使用Spring Cache,Spring Framework 4.3和Spring Boot 1.4提供了Caffeine支持。

Guice

通过JCache provider为JSR提供了集成模块。

implementation 'org.jsr107.ri:cache-annotations-ri-guice:1.1.0'
Injector injector = Guice.createInjector(new CacheAnnotationsModule());

CDI

通过JCache provider为JSR提供了扩展。

implementation 'org.jsr107.ri:cache-annotations-ri-cdi:1.1.0'