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
ConstructorDescriptionInMemorySessionStore
(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:SessionStore
Create a new unsaved session.- Specified by:
newSession
in interfaceSessionStore<InMemorySession>
- Returns:
- The created session
-
findSession
Description copied from interface:SessionStore
Find a session for the given ID.- Specified by:
findSession
in interfaceSessionStore<InMemorySession>
- Parameters:
id
- The ID of the session- Returns:
- A future the completes with an
Optional
session
-
deleteSession
Description copied from interface:SessionStore
Delete a session for the given ID.- Specified by:
deleteSession
in interfaceSessionStore<InMemorySession>
- Parameters:
id
- The ID of the session- Returns:
- A future that outputs
true
if the session was successfully deleted
-
save
Description copied from interface:SessionStore
Save the given session.- Specified by:
save
in 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
-