Commit 213326fd authored by Kelly Zhou's avatar Kelly Zhou Committed by Mingyang Zhu
Browse files

add clientOprtions to redis cache construction

parent 3672fc12
package org.opengroup.osdu.partition.provider.azure.di;
import com.azure.security.keyvault.secrets.SecretClient;
import com.lambdaworks.redis.ClientOptions;
import com.lambdaworks.redis.SocketOptions;
import org.opengroup.osdu.azure.KeyVaultFacade;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.partition.model.PartitionInfo;
......@@ -11,6 +13,7 @@ import org.springframework.context.annotation.Configuration;
import javax.inject.Named;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Configuration
public class RedisConfig {
......@@ -42,12 +45,18 @@ public class RedisConfig {
@Bean
public RedisCache<String, PartitionInfo> partitionServiceCache(@Named("REDIS_HOST") String host, @Named("REDIS_PASSWORD") String password) {
return new RedisCache<>(host, port, password, expiration, database, String.class, PartitionInfo.class);
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.build();
return new RedisCache<>(host, port, password, expiration, database, clientOptions, String.class, PartitionInfo.class);
}
@Bean
public RedisCache<String, List<String>> partitionListCache(@Named("REDIS_HOST") String host, @Named("REDIS_PASSWORD") String password) {
return new RedisCache(host, port, password, expiration, database, String.class, List.class);
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.build();
return new RedisCache(host, port, password, expiration, database, clientOptions, String.class, List.class);
}
}
......@@ -67,12 +76,18 @@ public class RedisConfig {
@Bean
public RedisCache<String, PartitionInfo> partitionServiceCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, expiration, database, String.class, PartitionInfo.class);
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.build();
return new RedisCache<>(host, port, expiration, database, clientOptions, String.class, PartitionInfo.class);
}
@Bean
public RedisCache<String, List<String>> partitionListCache(@Named("REDIS_HOST") String host) {
return new RedisCache(host, port, expiration, database, String.class, List.class);
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.build();
return new RedisCache(host, port, expiration, database, clientOptions, String.class, List.class);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment