Skip to main content

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

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

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