package fi.nls.oskari.spring.session;

import fi.nls.oskari.util.PropertyUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

// TODO: Check if maxInactiveIntervalInSeconds can be configured
@Configuration
@Profile(RedisSessionConfig.PROFILE)
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=7200)
public class RedisSessionConfig extends WebMvcConfigurerAdapter {

    public static final String PROFILE ="redis-session";

    @Bean
    public JedisConnectionFactory connectionFactory() {
        JedisConnectionFactory jedis = new JedisConnectionFactory();
        jedis.setHostName(PropertyUtil.get("redis.hostname", "127.0.0.1"));
        jedis.setPort(PropertyUtil.getOptional("redis.port", 6379));
        jedis.setUsePool(true);
        return jedis;
    }
}

@@ -240,16 +240,95 @@
 rofile;%0A
+import org.springframework.data.redis.connection.RedisStandaloneConfiguration;%0A
 import o
@@ -957,95 +957,96 @@
     
-J
+R
 edis
-ConnectionFactory jedis
+StandaloneConfiguration config
  = new 
-J
+R
 edis
-ConnectionFactory();%0A        jedis.setHostName(
+StandaloneConfiguration(%0A                
 Prop
@@ -1088,18 +1088,17 @@
 .0.0.1%22)
-);
+,
 %0A       
@@ -1102,22 +1102,16 @@
     
-jedis.setPort(
+        
 Prop
@@ -1165,29 +1165,72 @@
     
-j
+J
 edis
-.setUsePool(true
+ConnectionFactory jedis = new JedisConnectionFactory(config
 );%0A 

Update redis config from deprecated - pooling enabled by default