如何在Spring WebFlux中实现类似于spring-mvc会话管理的“最大会话”?

时间:2018-06-29 14:30:59

标签: spring-webflux

在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);
    }
}

0 个答案:

没有答案