Commit 331d1e93 authored by Shiv Singh's avatar Shiv Singh
Browse files

[+] added RedisAzureCache

parent 68596078
Pipeline #96914 failed with stages
in 5 minutes and 24 seconds
......@@ -14,92 +14,33 @@
package org.opengroup.osdu.search.provider.azure.config.cache;
import javax.inject.Named;
import org.opengroup.osdu.azure.KeyVaultFacade;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.azure.cache.RedisAzureCache;
import org.opengroup.osdu.core.common.model.entitlements.Groups;
import org.opengroup.osdu.core.common.model.search.ClusterSettings;
import org.opengroup.osdu.core.common.model.search.CursorSettings;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.azure.security.keyvault.secrets.SecretClient;
@Configuration
public class RedisConfig {
@Bean
@Named("REDIS_HOST")
public String redisHost(SecretClient kv) {
return KeyVaultFacade.getSecretWithValidation(kv, "redis-hostname");
}
@Bean
@Named("REDIS_PASSWORD")
public String redisPassword(SecretClient kv) {
return KeyVaultFacade.getSecretWithValidation(kv, "redis-password");
}
@Configuration
@ConditionalOnExpression(value = "'${cache.provider}' == 'redis' && '${redis.ssl.enabled:false}'")
@ConditionalOnExpression(value = "'${cache.provider}' == 'redis'")
static class SslConfig {
@Value("${redis.port}")
private int port;
@Value("${redis.expiration}")
private int expiration;
@Value("${redis.database}")
private int database;
@Bean
public RedisCache<String, Groups> groupCache(@Named("REDIS_HOST") String host, @Named("REDIS_PASSWORD") String password) {
return new RedisCache<>(host, port, password, expiration, database, String.class, Groups.class);
public RedisAzureCache<String, Groups> groupCache() {
return new RedisAzureCache<>(String.class, Groups.class);
}
@Bean
public RedisCache<String, CursorSettings> cursorCache(@Named("REDIS_HOST") String host, @Named("REDIS_PASSWORD") String password) {
return new RedisCache<>(host, port, password, expiration, database, String.class, CursorSettings.class);
public RedisAzureCache<String, CursorSettings> cursorCache() {
return new RedisAzureCache<>(String.class, CursorSettings.class);
}
@Bean
public RedisCache<String, ClusterSettings> clusterCache(@Named("REDIS_HOST") String host, @Named("REDIS_PASSWORD") String password) {
return new RedisCache<>(host, port, password, expiration, database, String.class, ClusterSettings.class);
public RedisAzureCache<String, ClusterSettings> clusterCache() {
return new RedisAzureCache<>(String.class, ClusterSettings.class);
}
}
@Configuration
@ConditionalOnExpression(value = "'${cache.provider}' == 'redis' && !'${redis.ssl.enabled:true}'")
static class NoSslConfig {
@Value("${redis.port}")
private int port;
@Value("${redis.database}")
private int database;
@Value("${redis.expiration}")
private int expiration;
@Bean
public RedisCache<String, Groups> groupCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, expiration, database, String.class, Groups.class);
}
@Bean
public RedisCache<String, CursorSettings> cursorCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, expiration, database, String.class, CursorSettings.class);
}
@Bean
public RedisCache<String, ClusterSettings> clusterCache(@Named("REDIS_HOST") String host) {
return new RedisCache<>(host, port, expiration, database, String.class, ClusterSettings.class);
}
}
}
Supports Markdown
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