Commit 2ec729f6 authored by Bill Wang's avatar Bill Wang
Browse files

update cache

parent 04694db6
......@@ -51,7 +51,7 @@
<dependency>
<groupId>org.opengroup.osdu.core.aws</groupId>
<artifactId>os-core-lib-aws</artifactId>
<version>0.11.0-SNAPSHOT</version>
<version>0.11.0-ElastiCache-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
......
......@@ -14,6 +14,7 @@
package org.opengroup.osdu.search.provider.aws.cache;
import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.core.common.provider.interfaces.IIndexCache;
import org.springframework.beans.factory.annotation.Value;
......@@ -22,19 +23,25 @@ import org.springframework.stereotype.Component;
@Component
public class IndexCacheImpl implements IIndexCache<String, Boolean>, AutoCloseable {
private RedisCache<String, Boolean> cache;
private ICache<String, Boolean> cache;
private Boolean local;
public IndexCacheImpl(@Value("${aws.elasticache.cluster.index.endpoint}") final String REDIS_SEARCH_HOST,
@Value("${aws.elasticache.cluster.index.port}") final String REDIS_SEARCH_PORT,
@Value("${aws.elasticache.cluster.index.key}") final String REDIS_SEARCH_KEY,
@Value("${aws.elasticache.cluster.index.expiration}") final String INDEX_CACHE_EXPIRATION) {
cache = new RedisCache<>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT), REDIS_SEARCH_KEY,
Integer.parseInt(INDEX_CACHE_EXPIRATION) * 60, String.class, Boolean.class);
local = cache.getClass() != RedisCache.class;
}
@Override
public void close() throws Exception {
this.cache.close();
if (this.local){
// local dummy cache, no need to close
}else{
((RedisCache)this.cache).close();
}
}
@Override
......
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