0

I have built up a redis server, I want to know whether I can make spring-session use the existed redis server instead of embed its redis-server?

Hongyu Jiang
  • 41
  • 2
  • 8

1 Answers1

2

Yes Spring Session can and should use an existing Redis Server. This is the primary way to deploy to production. I have provided a few examples below:

Spring Boot

Taking the Spring Boot Sample and converting it to use an external Redis Server can be done by:

Other Samples

The other samples are quite similar to use an external Redis instance. For example, to change the httpsession sample to use an external Redis:

For example:

@Bean
public JedisConnectionFactory connectionFactory() {
    JedisConnectionFactory connection = new JedisConnectionFactory();
    connection.setPort(6379);
    connection.setHostName("example.com");
    connection.setPassword("secret");
    return connection;
}
Rob Winch
  • 21,440
  • 2
  • 59
  • 76