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

Merge branch 'records_redis_cache_for_azure' into 'master'

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

See merge request !572
parents fb77f341 ff2ab9ae
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 #198553 failed
...@@ -362,7 +362,7 @@ The following software have components provided under the terms of this license: ...@@ -362,7 +362,7 @@ The following software have components provided under the terms of this license:
- AssertJ Core (from ${project.organization.url}#${project.artifactId}) - AssertJ Core (from ${project.organization.url}#${project.artifactId})
- Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) - Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client)
- Asynchronous Http Client Netty Utils (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client-netty-utils) - Asynchronous Http Client Netty Utils (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client-netty-utils)
- AutoValue Annotations (from https://github.com/google/auto/tree/master/value, https://repo1.maven.org/maven2/com/google/auto/value/auto-value-annotations) - AutoValue Annotations (from https://github.com/google/auto/tree/main/value, https://github.com/google/auto/tree/master/value, https://repo1.maven.org/maven2/com/google/auto/value/auto-value-annotations)
- BSON (from http://bsonspec.org, https://bsonspec.org) - BSON (from http://bsonspec.org, https://bsonspec.org)
- BSON Record Codec (from <https://www.mongodb.com/>, https://www.mongodb.com/) - BSON Record Codec (from <https://www.mongodb.com/>, https://www.mongodb.com/)
- Bean Validation API (from http://beanvalidation.org) - Bean Validation API (from http://beanvalidation.org)
......
...@@ -18,7 +18,5 @@ package org.opengroup.osdu.indexer.cache; ...@@ -18,7 +18,5 @@ package org.opengroup.osdu.indexer.cache;
import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.model.storage.RecordData; import org.opengroup.osdu.core.common.model.storage.RecordData;
import java.util.Map;
public interface IRelatedObjectCache extends ICache<String, RecordData> { public interface IRelatedObjectCache extends ICache<String, RecordData> {
} }
...@@ -25,7 +25,7 @@ public class RecordChangeInfoCacheVmImpl implements IRecordChangeInfoCache { ...@@ -25,7 +25,7 @@ public class RecordChangeInfoCacheVmImpl implements IRecordChangeInfoCache {
private VmCache<String, RecordChangeInfo> cache; private VmCache<String, RecordChangeInfo> cache;
public RecordChangeInfoCacheVmImpl() { public RecordChangeInfoCacheVmImpl() {
cache = new VmCache<>(Constants.DATA_CACHE_EXPIRATION, Constants.DATA_MAX_CACHE_SIZE); cache = new VmCache<>(Constants.DATA_CHANGE_INFO_CACHE_EXPIRATION, Constants.DATA_MAX_CACHE_SIZE);
} }
@Override @Override
......
...@@ -20,8 +20,6 @@ import org.opengroup.osdu.core.common.model.storage.RecordData; ...@@ -20,8 +20,6 @@ import org.opengroup.osdu.core.common.model.storage.RecordData;
import org.opengroup.osdu.indexer.model.Constants; import org.opengroup.osdu.indexer.model.Constants;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Map;
@Component @Component
public class RelatedObjectCacheVmImpl implements IRelatedObjectCache { public class RelatedObjectCacheVmImpl implements IRelatedObjectCache {
private VmCache<String, RecordData> cache; private VmCache<String, RecordData> cache;
......
...@@ -21,9 +21,10 @@ public class Constants { ...@@ -21,9 +21,10 @@ public class Constants {
// Specifications using kind as key is not partition safe if the specifications are per data partition // 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_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 // Data id itself is partition safe
public static final int DATA_CACHE_EXPIRATION = 120; public static final int DATA_CACHE_EXPIRATION = 120;
public static final int DATA_MAX_CACHE_SIZE = 2000; public static final int DATA_CHANGE_INFO_CACHE_EXPIRATION = 3600;
public static final int DATA_MAX_CACHE_SIZE = 20000;
} }
/*
* Copyright © Schlumberger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0 *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import javax.inject.Named;
@Component
@Primary
@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("RECORD_CHANGE_INFO_REDIS_TTL") int timeout,
@Value("${redis.database}") final int database) {
super(host, port, password, timeout, database, String.class, RecordChangeInfo.class);
}
}
/*
* Copyright © Schlumberger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0 *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import javax.inject.Named;
@Component
@Primary
@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,
@Value("${redis.database}") final int database) {
super(host, port, password, timeout, database, String.class, RecordData.class);
}
}
...@@ -38,6 +38,12 @@ public class RedisConfig { ...@@ -38,6 +38,12 @@ public class RedisConfig {
@Value("${redis.schema.ttl:3600}") @Value("${redis.schema.ttl:3600}")
public int schemaTtl; public int schemaTtl;
@Value("${redis.records.ttl:120}")
public int recordsTtl;
@Value("${redis.record.change.info.ttl:3600}")
public int recordChangeInfoTtl;
@Bean @Bean
@Named("REDIS_PORT") @Named("REDIS_PORT")
public int getRedisPort() { public int getRedisPort() {
...@@ -62,6 +68,18 @@ public class RedisConfig { ...@@ -62,6 +68,18 @@ public class RedisConfig {
return schemaTtl; return schemaTtl;
} }
@Bean
@Named("RECORDS_REDIS_TTL")
public int getRecordsRedisTtl() {
return recordsTtl;
}
@Bean
@Named("RECORD_CHANGE_INFO_REDIS_TTL")
public int getRecordChangeInfoRedisTtl() {
return recordChangeInfoTtl;
}
@Bean @Bean
@Named("REDIS_HOST") @Named("REDIS_HOST")
public String redisHost(SecretClient kv) { 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