Skip to content
Snippets Groups Projects
Commit 4d706a6a authored by Zhibin Mai's avatar Zhibin Mai
Browse files

Implement Redis cache in Azure for two kinds of object caches that are...

Implement Redis cache in Azure for two kinds of object caches that are required to be synchronized across the indexer service
parent c6ce3250
No related branches found
No related tags found
1 merge request!572Implement Redis cache in Azure for two kinds of object caches that are...
Pipeline #195458 failed
......@@ -21,9 +21,9 @@ public class Constants {
// Specifications using kind as key is not partition safe if the specifications are per data partition
public static final int SPEC_CACHE_EXPIRATION = 600;
public static final int SPEC_MAX_CACHE_SIZE = 2000;
public static final int SPEC_MAX_CACHE_SIZE = 20000;
// Data id itself is partition safe
public static final int DATA_CACHE_EXPIRATION = 120;
public static final int DATA_MAX_CACHE_SIZE = 2000;
public static final int DATA_MAX_CACHE_SIZE = 20000;
}
package org.opengroup.osdu.indexer.azure.cache;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.indexer.cache.IRecordChangeInfoCache;
import org.opengroup.osdu.indexer.model.RecordChangeInfo;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import javax.inject.Named;
@Component
@ConditionalOnProperty(value = "runtime.env.local", havingValue = "false", matchIfMissing = true)
public class RecordChangeInfoRedisCache extends RedisCache<String, RecordChangeInfo> implements IRecordChangeInfoCache {
public RecordChangeInfoRedisCache(final @Named("REDIS_HOST") String host,
final @Named("REDIS_PORT") int port,
final @Named("REDIS_PASSWORD") String password,
final @Named("RECORDS_REDIS_TTL") int timeout,
@Qualifier("") @Value("${redis.database}") final int database) {
super(host, port, password, timeout, database, String.class, RecordChangeInfo.class);
}
}
package org.opengroup.osdu.indexer.azure.cache;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.core.common.model.storage.RecordData;
import org.opengroup.osdu.indexer.cache.IRelatedObjectCache;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import javax.inject.Named;
@Component
@ConditionalOnProperty(value = "runtime.env.local", havingValue = "false", matchIfMissing = true)
public class RelatedObjectRedisCache extends RedisCache<String, RecordData> implements IRelatedObjectCache {
public RelatedObjectRedisCache(final @Named("REDIS_HOST") String host,
final @Named("REDIS_PORT") int port,
final @Named("REDIS_PASSWORD") String password,
final @Named("RECORDS_REDIS_TTL") int timeout,
@Qualifier("") @Value("${redis.database}") final int database) {
super(host, port, password, timeout, database, String.class, RecordData.class);
}
}
......@@ -38,6 +38,9 @@ public class RedisConfig {
@Value("${redis.schema.ttl:3600}")
public int schemaTtl;
@Value("${redis.records.ttl:120}")
public int recordsTtl;
@Bean
@Named("REDIS_PORT")
public int getRedisPort() {
......@@ -62,6 +65,12 @@ public class RedisConfig {
return schemaTtl;
}
@Bean
@Named("RECORDS_REDIS_TTL")
public int getRecordsRedisTtl() {
return recordsTtl;
}
@Bean
@Named("REDIS_HOST")
public String redisHost(SecretClient kv) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment