ExpiringMap
added in: v0.1.0
Description
This provider uses Jodah ExpiringMap to fulfill the Xanthic Cache
contract.
Due to Jodah limitations, removal listeners will always observe the RemovalCause.OTHER
.
Consider using Caffeine or Cache2k for better performance and thread-safety.
Installation
- Gradle
- Gradle - Kotlin DSL
- Maven
build.gradle
dependencies {
implementation 'io.github.xanthic.cache:cache-provider-expiringmap'
}
build.gradle.kts
dependencies {
implementation("io.github.xanthic.cache:cache-provider-expiringmap")
}
pom.xml
<dependency>
<groupId>io.github.xanthic.cache</groupId>
<artifactId>cache-provider-expiringmap</artifactId>
</dependency>
Usage
Default
CacheApiSettings.getInstance().setDefaultCacheProvider(new ExpiringMapProvider());
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 ExpiringMapProvider());
});