Java 类org.springframework.cache.annotation.CacheConfig 实例源码

项目:busi-support    文件:CustomerRedisCacheManager.java   
private void addCacheExpires(final Class clazz, final Map<String, Long> cacheExpires) {
    ReflectionUtils.doWithMethods(clazz, method -> {
        ReflectionUtils.makeAccessible(method);
        CacheDuration cacheDuration = findCacheDuration(clazz, method);
        Cacheable cacheable = findAnnotation(method, Cacheable.class);
        CacheConfig cacheConfig = findAnnotation(clazz, CacheConfig.class);
        Set<String> cacheNames = findCacheNames(cacheConfig, cacheable);
        for (String cacheName : cacheNames) {
            if (cacheDuration != null) {
                cacheExpires.put(cacheName, cacheDuration.expireSeconds());
            }
        }
    }, method -> null != findAnnotation(method, Cacheable.class));
}
项目:iBase4J-Common    文件:BaseService.java   
/**
 * @return
 */
private String getCacheKey() {
    Class<?> cls = getClass();
    String cacheName = Constants.cacheKeyMap.get(cls);
    if (StringUtils.isBlank(cacheName)) {
        CacheConfig cacheConfig = cls.getAnnotation(CacheConfig.class);
        if (cacheConfig != null && ArrayUtils.isNotEmpty(cacheConfig.cacheNames())) {
            cacheName = cacheConfig.cacheNames()[0];
        } else {
            cacheName = getClass().getName();
        }
        Constants.cacheKeyMap.put(cls, cacheName);
    }
    return cacheName;
}
项目:automat    文件:BaseService.java   
/**
 * @return
 */
private String getCacheKey() {
    Class<?> cls = getClass();
    String cacheName = Constants.cacheKeyMap.get(cls);
    if (StringUtils.isBlank(cacheName)) {
        CacheConfig cacheConfig = cls.getAnnotation(CacheConfig.class);
        if (cacheConfig == null || cacheConfig.cacheNames() == null || cacheConfig.cacheNames().length < 1) {
            cacheName = getClass().getName();
        } else {
            cacheName = cacheConfig.cacheNames()[0];
        }
        Constants.cacheKeyMap.put(cls, cacheName);
    }
    return cacheName;
}
项目:iBase4J    文件:BaseService.java   
/** 获取缓存键值 */
protected String getCacheKey(Object id) {
    String cacheName = null;
    CacheConfig cacheConfig = getClass().getAnnotation(CacheConfig.class);
    if (cacheConfig == null || cacheConfig.cacheNames() == null || cacheConfig.cacheNames().length < 1) {
        cacheName = getClass().getName();
    } else {
        cacheName = cacheConfig.cacheNames()[0];
    }
    return new StringBuilder(Constants.CACHE_NAMESPACE).append(cacheName).append(":").append(id).toString();
}
项目:bird-java    文件:AbstractServiceImpl.java   
/**
 * @return
 */
private String getCacheKey() {
    Class<?> cls = getClass();
    String cacheName = Constants.cacheKeyMap.get(cls);
    if (StringUtils.isBlank(cacheName)) {
        CacheConfig cacheConfig = cls.getAnnotation(CacheConfig.class);
        if (cacheConfig == null || cacheConfig.cacheNames() == null || cacheConfig.cacheNames().length < 1) {
            cacheName = getClass().getName();
        } else {
            cacheName = cacheConfig.cacheNames()[0];
        }
        Constants.cacheKeyMap.put(cls, cacheName);
    }
    return cacheName;
}
项目:JAVA-    文件:BaseService.java   
/**
 * @return
 */
private String getCacheKey() {
    Class<?> cls = getClass();
    String cacheName = Constants.cacheKeyMap.get(cls);
    if (StringUtils.isBlank(cacheName)) {
        CacheConfig cacheConfig = cls.getAnnotation(CacheConfig.class);
        if (cacheConfig != null && ArrayUtils.isNotEmpty(cacheConfig.cacheNames())) {
            cacheName = cacheConfig.cacheNames()[0];
        } else {
            cacheName = getClass().getName();
        }
        Constants.cacheKeyMap.put(cls, cacheName);
    }
    return cacheName;
}
项目:springbootWeb    文件:CustomerRedisCacheManager.java   
private void addCacheExpires(final Class clazz, final Map<String, Long> cacheExpires) {
    ReflectionUtils.doWithMethods(clazz, method -> {
        ReflectionUtils.makeAccessible(method);
        CacheDuration cacheDuration = findCacheDuration(clazz, method);
        Cacheable cacheable = findAnnotation(method, Cacheable.class);
        CacheConfig cacheConfig = findAnnotation(clazz, CacheConfig.class);
        Set<String> cacheNames = findCacheNames(cacheConfig, cacheable);
        for (String cacheName : cacheNames) {
            if (cacheDuration != null) {
                cacheExpires.put(cacheName, cacheDuration.expireSeconds());
            }
        }
    }, method -> null != findAnnotation(method, Cacheable.class));
}
项目:busi-support    文件:CustomerRedisCacheManager.java   
private HashSet<String> findCacheNames(CacheConfig cacheConfig, Cacheable cacheable) {
    return cacheable.value().length == 0 ? new HashSet<>(Arrays.asList(cacheConfig.cacheNames())) : new HashSet<>(Arrays.asList(cacheable.value()));
}
项目:springbootWeb    文件:CustomerRedisCacheManager.java   
private HashSet<String> findCacheNames(CacheConfig cacheConfig, Cacheable cacheable) {
    return cacheable.value().length == 0 ? new HashSet<>(Arrays.asList(cacheConfig.cacheNames())) : new HashSet<>(Arrays.asList(cacheable.value()));
}