在Spring Webflux Web应用程序中,没有人知道如何将会话限制为每个用户一个会话吗?
配置:
@Configuration
@EnableRedisWebSession
@Slf4j
public class Session {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private int port;
@Value("${spring.redis.password}")
private String password;
@Value("${spring.redis.database}")
private int dbIndex;
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
configuration.setHostName(host);
configuration.setPort(port);
configuration.setDatabase(dbIndex);
configuration.setPassword(RedisPassword.of(password));
return new LettuceConnectionFactory(configuration);
}
}