From 6d56ca54c73dcf42c02560847521b93d6cbb84bd Mon Sep 17 00:00:00 2001 From: zhijie wang <wanzhiji@amazon.com> Date: Mon, 16 Aug 2021 22:52:12 -0700 Subject: [PATCH] update pom --- provider/indexer-aws/pom.xml | 2 +- .../osdu/indexer/aws/cache/SchemaCacheImpl.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/provider/indexer-aws/pom.xml b/provider/indexer-aws/pom.xml index 11edf9f28..a80e0854d 100644 --- a/provider/indexer-aws/pom.xml +++ b/provider/indexer-aws/pom.xml @@ -42,7 +42,7 @@ <dependency> <groupId>org.opengroup.osdu.indexer</groupId> <artifactId>indexer-core</artifactId> - <version>0.11.0-SNAPSHOT</version> + <version>0.11.0-ElasticCache-SNAPSHOT</version> </dependency> <dependency> <groupId>org.opengroup.osdu.core.aws</groupId> diff --git a/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/cache/SchemaCacheImpl.java b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/cache/SchemaCacheImpl.java index 5b8b8f02e..c8c13a334 100644 --- a/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/cache/SchemaCacheImpl.java +++ b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/cache/SchemaCacheImpl.java @@ -14,6 +14,7 @@ package org.opengroup.osdu.indexer.aws.cache; +import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.cache.RedisCache; import org.opengroup.osdu.indexer.provider.interfaces.ISchemaCache; import org.springframework.beans.factory.annotation.Value; @@ -22,19 +23,29 @@ import org.springframework.stereotype.Component; @Component public class SchemaCacheImpl implements ISchemaCache<String, String>, AutoCloseable { - private RedisCache<String, String> cache; - + private ICache<String, String> cache; + private Boolean local = false; public SchemaCacheImpl(@Value("${aws.elasticache.cluster.endpoint}") final String REDIS_SEARCH_HOST, @Value("${aws.elasticache.cluster.port}") final String REDIS_SEARCH_PORT, @Value("${aws.elasticache.cluster.key}") final String REDIS_SEARCH_KEY, @Value("${aws.elasticache.cluster.schema.expiration}") final String SCHEMA_CACHE_EXPIRATION) { cache = new RedisCache<>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT), REDIS_SEARCH_KEY, Integer.parseInt(SCHEMA_CACHE_EXPIRATION) * 60, String.class, String.class); + if (cache.getClass() == RedisCache.class){ + local = false; + }else{ + local = true; + } } @Override public void close() throws Exception { - this.cache.close(); + if (this.local){ + // do nothing, this is using local dummy cache + }else { + // cast to redis cache so it can be closed + ((RedisCache)this.cache).close(); + } } @Override -- GitLab