Skip to main content

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​

build.gradle
dependencies {
implementation 'io.github.xanthic.cache:cache-provider-expiringmap'
}

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());
});