當前位置: 首頁>>代碼示例>>Java>>正文


Java CacheConfig類代碼示例

本文整理匯總了Java中org.springframework.cache.annotation.CacheConfig的典型用法代碼示例。如果您正苦於以下問題:Java CacheConfig類的具體用法?Java CacheConfig怎麽用?Java CacheConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CacheConfig類屬於org.springframework.cache.annotation包,在下文中一共展示了CacheConfig類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addCacheExpires

import org.springframework.cache.annotation.CacheConfig; //導入依賴的package包/類
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));
}
 
開發者ID:DomKing,項目名稱:busi-support,代碼行數:15,代碼來源:CustomerRedisCacheManager.java

示例2: getCacheKey

import org.springframework.cache.annotation.CacheConfig; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:18,代碼來源:BaseService.java

示例3: getCacheKey

import org.springframework.cache.annotation.CacheConfig; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:18,代碼來源:BaseService.java

示例4: getCacheKey

import org.springframework.cache.annotation.CacheConfig; //導入依賴的package包/類
/** 獲取緩存鍵值 */
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();
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:12,代碼來源:BaseService.java

示例5: getCacheKey

import org.springframework.cache.annotation.CacheConfig; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:liuxx001,項目名稱:bird-java,代碼行數:18,代碼來源:AbstractServiceImpl.java

示例6: getCacheKey

import org.springframework.cache.annotation.CacheConfig; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:18,代碼來源:BaseService.java

示例7: findCacheNames

import org.springframework.cache.annotation.CacheConfig; //導入依賴的package包/類
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()));
}
 
開發者ID:DomKing,項目名稱:busi-support,代碼行數:4,代碼來源:CustomerRedisCacheManager.java


注:本文中的org.springframework.cache.annotation.CacheConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。