org.nutz.boot.starter.caffeine.CaffeineInterceptor Maven / Gradle / Ivy
The newest version!
package org.nutz.boot.starter.caffeine;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.nutz.aop.InterceptorChain;
import org.nutz.aop.MethodInterceptor;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@IocBean(create = "init")
public class CaffeineInterceptor implements MethodInterceptor {
private static Log log = Logs.get();
private final ConcurrentMap> cacheMap = new ConcurrentHashMap<>();
private final Map cacheStrategyMap = new HashMap<>();
@Inject
protected PropertiesProxy conf;
protected KeyStringifier stringifier;
protected UpdateStrategy updateStrategy;
@Inject("refer:$ioc")
protected Ioc ioc;
private Cache getCache(CacheStrategy strategy) {
Cache cache = cacheMap.get(strategy);
if (cache == null) {
synchronized (strategy) {
cache = cacheMap.get(strategy);
if (cache == null) {
Caffeine
© 2015 - 2025 Weber Informatics LLC | Privacy Policy