@Override public Mono<WebSession> retrieveSession(String id) { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); InMemoryWebSession session = this.sessions.get(id); if (session == null) { return Mono.empty(); } else if (session.isExpired(now)) { this.sessions.remove(id); return Mono.empty(); } else { session.updateLastAccessTime(now); return Mono.just(session); } }
private void checkMaxSessionsLimit() { if (sessions.size() >= maxSessions) { expiredSessionChecker.removeExpiredSessions(clock.instant()); if (sessions.size() >= maxSessions) { throw new IllegalStateException("Max sessions limit reached: " + sessions.size()); } } }
@Override public Mono<WebSession> retrieveSession(String id) { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); InMemoryWebSession session = this.sessions.get(id); if (session == null) { return Mono.empty(); } else if (session.isExpired(now)) { this.sessions.remove(id); return Mono.empty(); } else { session.updateLastAccessTime(now); return Mono.just(session); } }
@Override public Mono<WebSession> retrieveSession(String id) { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); InMemoryWebSession session = this.sessions.get(id); if (session == null) { return Mono.empty(); } else if (session.isExpired(now)) { this.sessions.remove(id); return Mono.empty(); } else { session.updateLastAccessTime(now); return Mono.just(session); } }
@Override public Mono<Void> save() { if (sessions.size() >= maxSessions) { expiredSessionChecker.removeExpiredSessions(clock.instant()); if (sessions.size() >= maxSessions) { return Mono.error(new IllegalStateException("Max sessions limit reached: " + sessions.size())); } } if (!getAttributes().isEmpty()) { this.state.compareAndSet(State.NEW, State.STARTED); } InMemoryWebSessionStore.this.sessions.put(this.getId(), this); return Mono.empty(); }
/** * Check for expired sessions and remove them. Typically such checks are * kicked off lazily during calls to {@link #createWebSession() create} or * {@link #retrieveSession retrieve}, no less than 60 seconds apart. * This method can be called to force a check at a specific time. * @since 5.0.8 */ public void removeExpiredSessions() { this.expiredSessionChecker.removeExpiredSessions(this.clock.instant()); }
@Override public Mono<WebSession> createWebSession() { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); return Mono.fromSupplier(() -> new InMemoryWebSession(now)); }
@Override public Mono<WebSession> createWebSession() { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); return Mono.fromSupplier(() -> new InMemoryWebSession(now)); }
public void checkIfNecessary(Instant now) { if (this.checkTime.isBefore(now)) { removeExpiredSessions(now); } }
private void checkMaxSessionsLimit() { if (sessions.size() >= maxSessions) { expiredSessionChecker.removeExpiredSessions(clock.instant()); if (sessions.size() >= maxSessions) { throw new IllegalStateException("Max sessions limit reached: " + sessions.size()); } } }
/** * Check for expired sessions and remove them. Typically such checks are * kicked off lazily during calls to {@link #createWebSession() create} or * {@link #retrieveSession retrieve}, no less than 60 seconds apart. * This method can be called to force a check at a specific time. * @since 5.0.8 */ public void removeExpiredSessions() { this.expiredSessionChecker.removeExpiredSessions(this.clock.instant()); }
public void checkIfNecessary(Instant now) { if (this.checkTime.isBefore(now)) { removeExpiredSessions(now); } }
public void checkIfNecessary(Instant now) { if (this.checkTime.isBefore(now)) { removeExpiredSessions(now); } }
/** * Check for expired sessions and remove them. Typically such checks are * kicked off lazily during calls to {@link #createWebSession() create} or * {@link #retrieveSession retrieve}, no less than 60 seconds apart. * This method can be called to force a check at a specific time. * @since 5.0.8 */ public void removeExpiredSessions() { this.expiredSessionChecker.removeExpiredSessions(this.clock.instant()); }
@Override public Mono<WebSession> createWebSession() { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); return Mono.fromSupplier(() -> new InMemoryWebSession(now)); }
@Override public Mono<WebSession> retrieveSession(String id) { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); InMemoryWebSession session = this.sessions.get(id); if (session == null) { return Mono.empty(); } else if (session.isExpired(now)) { this.sessions.remove(id); return Mono.empty(); } else { session.updateLastAccessTime(now); return Mono.just(session); } }
private void checkMaxSessionsLimit() { if (sessions.size() >= maxSessions) { expiredSessionChecker.removeExpiredSessions(clock.instant()); if (sessions.size() >= maxSessions) { throw new IllegalStateException("Max sessions limit reached: " + sessions.size()); } } }
@Override public Mono<WebSession> createWebSession() { Instant now = this.clock.instant(); this.expiredSessionChecker.checkIfNecessary(now); return Mono.fromSupplier(() -> new InMemoryWebSession(now)); }
/** * Check for expired sessions and remove them. Typically such checks are * kicked off lazily during calls to {@link #createWebSession() create} or * {@link #retrieveSession retrieve}, no less than 60 seconds apart. * This method can be called to force a check at a specific time. * @since 5.0.8 */ public void removeExpiredSessions() { this.expiredSessionChecker.removeExpiredSessions(this.clock.instant()); }
public void checkIfNecessary(Instant now) { if (this.checkTime.isBefore(now)) { removeExpiredSessions(now); } }