Redis reads session once not twice during cleanup
I noticed that the session gets read twice at 4dc81ec10d/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisIndexedSessionRepository.java (L441-L442). This alters the code to only read it once.
This commit is contained in:
committed by
Marcus Hert Da Coregio
parent
9dbf18a5ab
commit
44a6da43fa
@@ -385,13 +385,17 @@ public class ReactiveRedisIndexedSessionRepository
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(String id) {
|
||||
return internalDeleteById(id).then();
|
||||
}
|
||||
|
||||
public Mono<Session> internalDeleteById(String id) {
|
||||
// @formatter:off
|
||||
return getSession(id, true)
|
||||
.flatMap((session) -> this.sessionRedisOperations.delete(getExpiredKey(session.getId()))
|
||||
.thenReturn(session))
|
||||
.flatMap((session) -> this.sessionRedisOperations.delete(getSessionKey(session.getId())).thenReturn(session))
|
||||
.flatMap((session) -> this.indexer.delete(session.getId()).thenReturn(session))
|
||||
.flatMap((session) -> this.expirationStore.remove(session.getId()));
|
||||
.flatMap((session) -> this.expirationStore.remove(session.getId()).thenReturn(session));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@@ -438,8 +442,7 @@ public class ReactiveRedisIndexedSessionRepository
|
||||
int sessionIdBeginIndex = key.lastIndexOf(":") + 1;
|
||||
return key.substring(sessionIdBeginIndex);
|
||||
})
|
||||
.flatMap((sessionId) -> getSession(sessionId, true))
|
||||
.flatMap((session) -> this.deleteById(session.getId()).thenReturn(session))
|
||||
.flatMap(this::internalDeleteById)
|
||||
.map((session) -> {
|
||||
if (message.getChannel().equals(this.sessionDeletedChannel)) {
|
||||
return new SessionDeletedEvent(this, session);
|
||||
|
||||
Reference in New Issue
Block a user