Caffeine 3
added in: v0.1.0
Description
This provider uses the high-performance Caffeine library to fulfill the Xanthic Cache
contract.
This module requires Java 11 or higher (and Android is not supported). If using Java 8, one can switch to the Caffeine provider instead.
Installation
- Gradle
- Gradle - Kotlin DSL
- Maven
build.gradle
dependencies {
implementation 'io.github.xanthic.cache:cache-provider-caffeine3'
}
build.gradle.kts
dependencies {
implementation("io.github.xanthic.cache:cache-provider-caffeine3")
}
pom.xml
<dependency>
<groupId>io.github.xanthic.cache</groupId>
<artifactId>cache-provider-caffeine3</artifactId>
</dependency>
Usage
Default
CacheApiSettings.getInstance().setDefaultCacheProvider(new Caffeine3Provider());
Cache<String, Integer> cache = CacheApi.create(spec -> {
// if spec.provider is not set the default cache provider will be used
});
Spec
Cache<String, Integer> cache = CacheApi.create(spec -> {
spec.provider(new Caffeine3Provider());
});