Skip to content

Commit 65a4429

Browse files
committed
Revert "Use simple Redis repository by default"
This reverts commit 8582b97 See gh-2122
1 parent 8c49d59 commit 65a4429

15 files changed

+330
-896
lines changed

spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/RedisIndexedSessionRepositoryITests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -691,7 +691,7 @@ private String getChangedSecurityName() {
691691
}
692692

693693
@Configuration
694-
@EnableRedisHttpSession(redisNamespace = "RedisIndexedSessionRepositoryITests", enableIndexingAndEvents = true)
694+
@EnableRedisHttpSession(redisNamespace = "RedisIndexedSessionRepositoryITests")
695695
static class Config extends BaseConfig {
696696

697697
@Bean

spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/RedisSessionRepositoryITests.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,10 +26,13 @@
2626
import org.junit.jupiter.api.extension.ExtendWith;
2727

2828
import org.springframework.beans.factory.annotation.Autowired;
29+
import org.springframework.context.annotation.Bean;
2930
import org.springframework.context.annotation.Configuration;
31+
import org.springframework.data.redis.connection.RedisConnectionFactory;
32+
import org.springframework.data.redis.core.RedisTemplate;
3033
import org.springframework.session.MapSession;
34+
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
3135
import org.springframework.session.data.redis.RedisSessionRepository.RedisSession;
32-
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
3336
import org.springframework.test.context.ContextConfiguration;
3437
import org.springframework.test.context.junit.jupiter.SpringExtension;
3538
import org.springframework.test.context.web.WebAppConfiguration;
@@ -220,9 +223,17 @@ private static void updateSession(RedisSession session, Instant lastAccessedTime
220223
}
221224

222225
@Configuration
223-
@EnableRedisHttpSession
226+
@EnableSpringHttpSession
224227
static class Config extends BaseConfig {
225228

229+
@Bean
230+
RedisSessionRepository sessionRepository(RedisConnectionFactory redisConnectionFactory) {
231+
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
232+
redisTemplate.setConnectionFactory(redisConnectionFactory);
233+
redisTemplate.afterPropertiesSet();
234+
return new RedisSessionRepository(redisTemplate);
235+
}
236+
226237
}
227238

228239
}

spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/config/annotation/web/http/EnableRedisHttpSessionExpireSessionDestroyedTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ void setLock(Object lock) {
113113
}
114114

115115
@Configuration
116-
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 1, enableIndexingAndEvents = true)
116+
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 1)
117117
static class Config extends BaseConfig {
118118

119119
@Bean

spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/taskexecutor/RedisListenerContainerTaskExecutorITests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -101,7 +101,7 @@ boolean taskDispatched() throws InterruptedException {
101101
}
102102

103103
@Configuration
104-
@EnableRedisHttpSession(redisNamespace = "RedisListenerContainerTaskExecutorITests", enableIndexingAndEvents = true)
104+
@EnableRedisHttpSession(redisNamespace = "RedisListenerContainerTaskExecutorITests")
105105
static class Config extends BaseConfig {
106106

107107
@Bean

spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/EnableRedisHttpSession.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@
3232
import org.springframework.session.SessionRepository;
3333
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
3434
import org.springframework.session.data.redis.RedisIndexedSessionRepository;
35-
import org.springframework.session.data.redis.RedisSessionRepository;
3635
import org.springframework.session.web.http.SessionRepositoryFilter;
3736

3837
/**
@@ -54,8 +53,7 @@
5453
* }
5554
* </pre>
5655
*
57-
* More advanced configurations can extend {@link RedisHttpSessionConfiguration} or
58-
* {@link RedisIndexedHttpSessionConfiguration} instead.
56+
* More advanced configurations can extend {@link RedisHttpSessionConfiguration} instead.
5957
*
6058
* @author Rob Winch
6159
* @author Vedran Pavic
@@ -65,7 +63,7 @@
6563
@Retention(RetentionPolicy.RUNTIME)
6664
@Target(ElementType.TYPE)
6765
@Documented
68-
@Import(RedisHttpSessionConfigurationSelector.class)
66+
@Import(RedisHttpSessionConfiguration.class)
6967
@Configuration(proxyBeanMethods = false)
7068
public @interface EnableRedisHttpSession {
7169

@@ -100,6 +98,13 @@
10098
*/
10199
FlushMode flushMode() default FlushMode.ON_SAVE;
102100

101+
/**
102+
* The cron expression for expired session cleanup job. By default runs every minute.
103+
* @return the session cleanup cron expression
104+
* @since 2.0.0
105+
*/
106+
String cleanupCron() default RedisHttpSessionConfiguration.DEFAULT_CLEANUP_CRON;
107+
103108
/**
104109
* Save mode for the session. The default is {@link SaveMode#ON_SET_ATTRIBUTE}, which
105110
* only saves changes made to session.
@@ -108,13 +113,4 @@
108113
*/
109114
SaveMode saveMode() default SaveMode.ON_SET_ATTRIBUTE;
110115

111-
/**
112-
* Indicate whether the {@link SessionRepository} should publish session events and
113-
* support fetching sessions by index. If true, a
114-
* {@link RedisIndexedSessionRepository} will be used in place of
115-
* {@link RedisSessionRepository}. This will result in slower performance.
116-
* @return true if indexing and events should be enabled, false otherwise
117-
*/
118-
boolean enableIndexingAndEvents() default false;
119-
120116
}

0 commit comments

Comments
 (0)