refactor: make session store redis by default
This commit is contained in:
@@ -7,7 +7,7 @@ import java.time.Duration;
|
||||
@ConfigurationProperties(prefix = "lingniu.ingest.session")
|
||||
public class SessionProperties {
|
||||
|
||||
private Store store = Store.MEMORY;
|
||||
private Store store = Store.REDIS;
|
||||
|
||||
private Duration ttl = Duration.ofMinutes(30);
|
||||
|
||||
@@ -16,6 +16,9 @@ public class SessionProperties {
|
||||
}
|
||||
|
||||
public void setStore(Store store) {
|
||||
if (store == Store.MEMORY) {
|
||||
throw new IllegalStateException("session.store supports only redis; configured value: memory");
|
||||
}
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,15 +17,10 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@EnableConfigurationProperties(SessionProperties.class)
|
||||
public class SessionCoreAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "lingniu.ingest.session", name = "store", havingValue = "memory")
|
||||
public Object rejectedLegacyMemorySessionStore() {
|
||||
throw new IllegalStateException("session.store=memory has been removed; configure session.store=redis");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(StringRedisTemplate.class)
|
||||
@ConditionalOnProperty(prefix = "lingniu.ingest.session", name = "store", havingValue = "redis")
|
||||
@ConditionalOnProperty(prefix = "lingniu.ingest.session", name = "store", havingValue = "redis",
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnMissingBean
|
||||
public SessionStore redisSessionStore(StringRedisTemplate redis, SessionProperties properties) {
|
||||
// Redis 只保存会话元数据索引;真实 Netty Channel 仍在各协议进程本地内存中。
|
||||
|
||||
Reference in New Issue
Block a user