A store implementation backed by Caffeine, a high performance caching library for Java 8.
Replace VERSION with the following:
repositories {
mavenCentral()
}
dependencies {
implementation 'com.discord4j:stores-caffeine:VERSION'
}<dependencies>
<dependency>
<groupId>com.discord4j</groupId>
<artifactId>stores-caffeine</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>libraryDependencies ++= Seq(
"com.discord4j" % "stores-caffeine" % "VERSION"
)CaffeineStoreService is considered a legacy store layout and must be configured accordingly at setStore:
DiscordClientBuilder.create(System.getenv("token"))
.build()
.gateway()
.setStore(Store.fromLayout(LegacyStoreLayout.of(new CaffeineStoreService(builder -> builder.maximumSize(10_000)
.expireAfterWrite(5, TimeUnit.MINUTES)
.refreshAfterWrite(1, TimeUnit.MINUTES)))))
.withGateway(client -> client.on(ReadyEvent.class)
.doOnNext(ready -> log.info("Logged in as {}", ready.getSelf().getUsername()))
.then())
.block();