com.ontology2.rdf.CacheEconomizer Maven / Gradle / Ivy
The newest version!
package com.ontology2.rdf;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
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);
}
}
}