Skip to content

Commit

Permalink
Merge pull request #6912 from ORCID/AddRedisconnectionTimeout
Browse files Browse the repository at this point in the history
add an option to configure timeout
  • Loading branch information
amontenegro authored Oct 24, 2023
2 parents e2e0c81 + 959728f commit 47bc234
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@
<constructor-arg index="1" value="${org.orcid.core.utils.cache.redis.port}" />
<constructor-arg index="2" value="${org.orcid.core.utils.cache.redis.password}" />
<constructor-arg index="3" value="${org.orcid.core.utils.cache.redis.expiration_in_secs:600}" />
<constructor-arg index="4" value="${org.orcid.core.utils.cache.redis.connection_timeout_millis:10000}" />
</bean>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.orcid.utils.alerting.SlackManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.HostAndPort;
Expand All @@ -24,7 +25,7 @@ public class RedisClient {
private static final Logger LOG = LoggerFactory.getLogger(RedisClient.class);

private static final int DEFAULT_CACHE_EXPIRY = 60;
private static final int DEFAULT_TIMEOUT = 5000;
private static final int DEFAULT_TIMEOUT = 10000;

private final String redisHost;
private final int redisPort;
Expand All @@ -37,7 +38,7 @@ public class RedisClient {
@Resource
private SlackManager slackManager;

// Assume the connection to Redis is disabled by default
// Assume the connection to Redis is disabled by default
private boolean enabled = false;

public RedisClient(String redisHost, int redisPort, String password) {
Expand Down Expand Up @@ -66,10 +67,6 @@ public RedisClient(String redisHost, int redisPort, String password, int cacheEx

@PostConstruct
private void init() {
if(!enabled) {
LOG.debug("Redis is not enabled, so, it will not be initilized");
return;
}
try {
JedisClientConfig config = DefaultJedisClientConfig.builder().connectionTimeoutMillis(this.clientTimeoutInMillis).timeoutMillis(this.clientTimeoutInMillis)
.socketTimeoutMillis(this.clientTimeoutInMillis).password(this.redisPassword).ssl(true).build();
Expand Down
1 change: 1 addition & 0 deletions orcid-core/src/main/resources/orcid-core-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@
<constructor-arg index="1" value="${org.orcid.core.utils.cache.redis.port}" />
<constructor-arg index="2" value="${org.orcid.core.utils.cache.redis.password}" />
<constructor-arg index="3" value="${org.orcid.core.utils.cache.redis.expiration_in_secs:600}" />
<constructor-arg index="4" value="${org.orcid.core.utils.cache.redis.connection_timeout_millis:10000}" />
</bean>

<bean id="emailDomainManager" class="org.orcid.core.common.manager.impl.EmailDomainManagerImpl"/>
Expand Down

0 comments on commit 47bc234

Please sign in to comment.