Caffeine
added in: v0.1.0
Description
This provider uses the high-performance Caffeine library to fulfill the Xanthic Cache
contract.
This module supports Java 8, but not Android. If using Java 11+, one can switch to the Caffeine3 provider instead.
Installation
- Gradle
- Gradle - Kotlin DSL
- Maven
build.gradle
dependencies {
implementation 'io.github.xanthic.cache:cache-provider-caffeine'
}
build.gradle.kts
dependencies {
implementation("io.github.xanthic.cache:cache-provider-caffeine")
}
pom.xml
<dependency>
<groupId>io.github.xanthic.cache</groupId>
<artifactId>cache-provider-caffeine</artifactId>
</dependency>
Usage
Default
CacheApiSettings.getInstance().setDefaultCacheProvider(new CaffeineProvider());
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 CaffeineProvider());
});