Package net.andreaskluth.session.core
Class ReactiveVertxSessionRepository
java.lang.Object
net.andreaskluth.session.core.ReactiveVertxSessionRepository
- All Implemented Interfaces:
org.springframework.session.ReactiveSessionRepository<ReactiveVertxSessionRepository.ReactiveSession>
public class ReactiveVertxSessionRepository extends java.lang.Object implements org.springframework.session.ReactiveSessionRepository<ReactiveVertxSessionRepository.ReactiveSession>
A
ReactiveSessionRepository using vert.x reactive database clients.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReactiveVertxSessionRepository.ReactiveSession -
Constructor Summary
Constructors Constructor Description ReactiveVertxSessionRepository(io.vertx.sqlclient.Pool pool, ReactiveVertxSessionRepositoryQueries repositoryQueries, SerializationStrategy serializationStrategy, java.time.Clock clock)Creates a new instance. -
Method Summary
Modifier and Type Method Description reactor.core.publisher.Mono<java.lang.Integer>cleanupExpiredSessions()reactor.core.publisher.Mono<ReactiveVertxSessionRepository.ReactiveSession>createSession()reactor.core.publisher.Mono<java.lang.Void>deleteById(java.lang.String id)reactor.core.publisher.Mono<ReactiveVertxSessionRepository.ReactiveSession>findById(java.lang.String id)reactor.core.publisher.Mono<java.lang.Void>save(ReactiveVertxSessionRepository.ReactiveSession reactiveSession)voidsetDefaultMaxInactiveInterval(java.time.Duration maxInactiveInterval)Sets the maximum inactive interval in seconds between requests before newly created sessions will be invalidated.voidsetInvalidateSessionOnDeserializationError(boolean invalidateSessionOnDeserializationError)Instead of propagatingDeserializationExceptionto the caller, nothing is returned resulting in the creation of a new session.voidsetMetricSequenceName(java.lang.String sequenceName)Set a custom sequence name used for metrics seeMono.name(String).voidwithMetrics(boolean enableMetrics)ActivatesMono.metrics()for all operations.
-
Constructor Details
-
ReactiveVertxSessionRepository
public ReactiveVertxSessionRepository(io.vertx.sqlclient.Pool pool, ReactiveVertxSessionRepositoryQueries repositoryQueries, SerializationStrategy serializationStrategy, java.time.Clock clock)Creates a new instance.- Parameters:
pool- the database poolrepositoryQueries- the sql queries to useserializationStrategy- theSerializationStrategyto read and write session data * withclock- theClockto use
-
-
Method Details
-
withMetrics
public void withMetrics(boolean enableMetrics)ActivatesMono.metrics()for all operations.- Parameters:
enableMetrics- whether metrics should be generated or not.
-
setInvalidateSessionOnDeserializationError
public void setInvalidateSessionOnDeserializationError(boolean invalidateSessionOnDeserializationError)Instead of propagatingDeserializationExceptionto the caller, nothing is returned resulting in the creation of a new session. This is useful if a java class stored in the session was updated and there is a serial version id mismatch.- Parameters:
invalidateSessionOnDeserializationError- whether serialization errors should be propagated to the caller.
-
setMetricSequenceName
public void setMetricSequenceName(java.lang.String sequenceName)Set a custom sequence name used for metrics seeMono.name(String).- Parameters:
sequenceName- overrides the default sequence name
-
setDefaultMaxInactiveInterval
public void setDefaultMaxInactiveInterval(java.time.Duration maxInactiveInterval)Sets the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never timeout. The default is 1800 (30 minutes).- Parameters:
maxInactiveInterval- theDurationthat theSessionshould be kept alive between client requests.
-
createSession
- Specified by:
createSessionin interfaceorg.springframework.session.ReactiveSessionRepository<ReactiveVertxSessionRepository.ReactiveSession>
-
save
public reactor.core.publisher.Mono<java.lang.Void> save(ReactiveVertxSessionRepository.ReactiveSession reactiveSession)- Specified by:
savein interfaceorg.springframework.session.ReactiveSessionRepository<ReactiveVertxSessionRepository.ReactiveSession>
-
findById
public reactor.core.publisher.Mono<ReactiveVertxSessionRepository.ReactiveSession> findById(java.lang.String id)- Specified by:
findByIdin interfaceorg.springframework.session.ReactiveSessionRepository<ReactiveVertxSessionRepository.ReactiveSession>
-
deleteById
public reactor.core.publisher.Mono<java.lang.Void> deleteById(java.lang.String id)- Specified by:
deleteByIdin interfaceorg.springframework.session.ReactiveSessionRepository<ReactiveVertxSessionRepository.ReactiveSession>
-
cleanupExpiredSessions
public reactor.core.publisher.Mono<java.lang.Integer> cleanupExpiredSessions()
-