1. Caffeine
SessionStore implementation using Caffeine library.
1.1. Usage
1) Add the dependency:
Maven
Gradle
<dependency>
<groupId>io.jooby</groupId>
<artifactId>jooby-caffeine</artifactId>
<version>3.5.3</version>
</dependency>
2) Configure session store
Java
Kotlin
import io.jooby.caffeine.CaffeineSessionStore;
{
setSessionStore(new CaffeineSessionStore()); (1)
get("/", ctx -> {
Session session = ctx.session(); (2)
// work with session
});
}
1 | Configure session store |
2 | Use HTTP Session |
Default time out is 30
minutes, to provide your own timeout:
new CaffeineSessionStore(Duration.ofHours(1))
For absolute control you can provide your own cache:
Cache cache = ...; new CaffeineSessionStore(Duration.ofHours(1))