本文整理匯總了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));
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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()));
}