com.ontology2.rdf.CacheEconomizer Maven / Gradle / Ivy
package com.ontology2.rdf;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
public class CacheEconomizer implements Economizer {
final Cache items=CacheBuilder.newBuilder().maximumSize(10000).build();
@Override
public T economize(final T that) {
try {
return items.get(that,new Callable() {
@Override
public T call() throws Exception {
return that;
}});
} catch(ExecutionException ex) {
throw new RuntimeException(ex);
}
}
}