Package io.micronaut.session
Class InMemorySessionStore
java.lang.Object
io.micronaut.session.InMemorySessionStore
- All Implemented Interfaces:
SessionStore<InMemorySession>
@Singleton
@Primary
public class InMemorySessionStore
extends Object
implements SessionStore<InMemorySession>
Default implementation that stores sessions in-memory.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Constructor Summary
ConstructorsConstructorDescriptionInMemorySessionStore(SessionIdGenerator sessionIdGenerator, SessionConfiguration sessionConfiguration, io.micronaut.context.event.ApplicationEventPublisher<? super AbstractSessionEvent> eventPublisher) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondeleteSession(String id) Delete a session for the given ID.findSession(String id) Find a session for the given ID.Create a new unsaved session.protected com.github.benmanes.caffeine.cache.Cache<String,InMemorySession> newSessionCache(SessionConfiguration configuration) Creates a new session cache.save(InMemorySession session) Save the given session.
-
Constructor Details
-
InMemorySessionStore
public InMemorySessionStore(SessionIdGenerator sessionIdGenerator, SessionConfiguration sessionConfiguration, io.micronaut.context.event.ApplicationEventPublisher<? super AbstractSessionEvent> eventPublisher) Constructor.- Parameters:
sessionIdGenerator- The session id generatorsessionConfiguration- The sessions configurationeventPublisher- The application event publisher
-
-
Method Details
-
newSession
Description copied from interface:SessionStoreCreate a new unsaved session.- Specified by:
newSessionin interfaceSessionStore<InMemorySession>- Returns:
- The created session
-
findSession
Description copied from interface:SessionStoreFind a session for the given ID.- Specified by:
findSessionin interfaceSessionStore<InMemorySession>- Parameters:
id- The ID of the session- Returns:
- A future the completes with an
Optionalsession
-
deleteSession
Description copied from interface:SessionStoreDelete a session for the given ID.- Specified by:
deleteSessionin interfaceSessionStore<InMemorySession>- Parameters:
id- The ID of the session- Returns:
- A future that outputs
trueif the session was successfully deleted
-
save
Description copied from interface:SessionStoreSave the given session.- Specified by:
savein interfaceSessionStore<InMemorySession>- Parameters:
session- The session to save- Returns:
- A future that completes with the saved session once the operation is complete
-
newSessionCache
protected com.github.benmanes.caffeine.cache.Cache<String,InMemorySession> newSessionCache(SessionConfiguration configuration) Creates a new session cache.- Parameters:
configuration- The session configuration- Returns:
- The new cache
-