io.github.xanthic.cache.provider.expiringmap.ExpiringMapProvider Maven / Gradle / Ivy
package io.github.xanthic.cache.provider.expiringmap;
import io.github.xanthic.cache.api.Cache;
import io.github.xanthic.cache.api.ICacheSpec;
import io.github.xanthic.cache.api.domain.ExpiryType;
import io.github.xanthic.cache.api.domain.RemovalCause;
import io.github.xanthic.cache.core.AbstractCacheProvider;
import io.github.xanthic.cache.core.delegate.GenericMapCacheDelegate;
import net.jodah.expiringmap.ExpirationPolicy;
import net.jodah.expiringmap.ExpiringMap;
import java.util.concurrent.TimeUnit;
/**
* Provides {@link Cache} instances using {@link ExpiringMap}.
*
* Implements size and time-based expiry.
*
* Note: listeners will always receive {@link RemovalCause#OTHER} due to limitations of the backing library.
*
* Consider using Caffeine or Cache2k for better performance.
*/
public final class ExpiringMapProvider extends AbstractCacheProvider {
@Override
public Cache build(ICacheSpec spec) {
ExpiringMap.Builder