-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b616230
commit f19e778
Showing
5 changed files
with
133 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
orcid-web/src/main/java/org/orcid/frontend/spring/configuration/SessionCacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.orcid.frontend.spring.configuration; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration; | ||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; | ||
import org.springframework.session.data.redis.config.ConfigureRedisAction; | ||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; | ||
import org.springframework.session.web.context.AbstractHttpSessionApplicationInitializer; | ||
import redis.clients.jedis.DefaultJedisClientConfig; | ||
import redis.clients.jedis.JedisClientConfig; | ||
|
||
import java.time.Duration; | ||
|
||
@Configuration | ||
@EnableRedisHttpSession | ||
public class SessionCacheConfig extends AbstractHttpSessionApplicationInitializer { | ||
|
||
@Value("${org.orcid.core.utils.cache.redis.host}") | ||
private String host; | ||
@Value("${org.orcid.core.utils.cache.redis.port}") | ||
private int port; | ||
@Value("${org.orcid.core.utils.cache.redis.password}") | ||
private String password; | ||
@Value("${org.orcid.core.utils.cache.redis.connection_timeout_millis:10000}") | ||
private int connectionTimeoutMillis; | ||
|
||
|
||
@Bean | ||
public JedisConnectionFactory connectionFactory() { | ||
Duration timeoutDuration = Duration.ofMillis(connectionTimeoutMillis); | ||
|
||
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); | ||
redisStandaloneConfiguration.setHostName(host); | ||
redisStandaloneConfiguration.setPort(port); | ||
redisStandaloneConfiguration.setPassword(password); | ||
|
||
JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfigurationBuilder = JedisClientConfiguration.builder(); | ||
jedisClientConfigurationBuilder.useSsl().and().connectTimeout(timeoutDuration).build(); | ||
|
||
return new JedisConnectionFactory(redisStandaloneConfiguration, jedisClientConfigurationBuilder.build()); | ||
} | ||
|
||
@Bean | ||
public static ConfigureRedisAction configureRedisAction() { | ||
return ConfigureRedisAction.NO_OP; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
orcid-web/src/main/java/org/orcid/frontend/spring/session/OrcidRedisSessionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.orcid.frontend.spring.session; | ||
|
||
import org.springframework.data.redis.core.RedisOperations; | ||
import org.springframework.session.data.redis.RedisSessionRepository; | ||
|
||
public class OrcidRedisSessionRepository extends RedisSessionRepository { | ||
|
||
public OrcidRedisSessionRepository(RedisOperations<String, Object> sessionRedisOperations) { | ||
super(sessionRedisOperations); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters