Guava
added in: v0.1.0
Description
This cache provider uses the popular Guava library.
For server-side users, Caffeine is recommended instead.
For Android users, Google suggests using LruCache
instead.
Installation
- Gradle
- Gradle - Kotlin DSL
- Maven
build.gradle
dependencies {
implementation 'io.github.xanthic.cache:cache-provider-guava'
}
build.gradle.kts
dependencies {
implementation("io.github.xanthic.cache:cache-provider-guava")
}
pom.xml
<dependency>
<groupId>io.github.xanthic.cache</groupId>
<artifactId>cache-provider-guava</artifactId>
</dependency>
Usage
Default
CacheApiSettings.getInstance().setDefaultCacheProvider(new GuavaProvider());
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 GuavaProvider());
});