com.ideaaedi.extspringcache.caffeine.ExtCaffeineCacheManager Maven / Gradle / Ivy
package com.ideaaedi.extspringcache.caffeine;
import com.github.benmanes.caffeine.cache.CacheLoader;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.CaffeineSpec;
import com.ideaaedi.extspringcache.annotation.ExtCacheableOop;
import com.ideaaedi.extspringcache.support.ExtCacheHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.cache.Cache;
import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* ext-caffeine 缓存管理器
*
*
* @author JustryDeng
* @since 2020/11/8 14:46:28
*/
public class ExtCaffeineCacheManager extends CaffeineCacheManager {
private boolean dynamic = true;
private final Map customCacheMap = new ConcurrentHashMap<>(16);
/**
* 创建Cache时,{@link CaffeineCacheManager#createCaffeineCache(String)} 会调用此方法的, 重写了此方法就相当于重写了createCaffeineCache。
*
* TIPS. 低版本的spring-boot里面,是没有此方法的,那时就需要重写{@link CaffeineCacheManager#createCaffeineCache(String)}了
*/
@NonNull
@Override
protected Cache adaptCaffeineCache(@Nullable String name,
@Nullable com.github.benmanes.caffeine.cache.Cache