Skip to content

Commit

Permalink
@CacheInvalidate and @CacheUpdate support Cache instance create by Ca…
Browse files Browse the repository at this point in the history
…cheManager.getOrCreateCache
  • Loading branch information
areyouok committed Aug 5, 2022
1 parent f3b10ef commit dcd20f4
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,27 @@ public CacheInvokeContext createCacheInvokeContext(ConfigMap configMap) {

private Cache createOrGetCache(CacheInvokeContext invokeContext, CacheAnnoConfig cacheAnnoConfig, ConfigMap configMap) {
Cache cache = cacheAnnoConfig.getCache();
if (cache == null) {
if (cacheAnnoConfig instanceof CachedAnnoConfig) {
cache = createCacheByCachedConfig((CachedAnnoConfig) cacheAnnoConfig, invokeContext);
} else if ((cacheAnnoConfig instanceof CacheInvalidateAnnoConfig) || (cacheAnnoConfig instanceof CacheUpdateAnnoConfig)) {
if (cache != null) {
return cache;
}
if (cacheAnnoConfig instanceof CachedAnnoConfig) {
cache = createCacheByCachedConfig((CachedAnnoConfig) cacheAnnoConfig, invokeContext);
} else if ((cacheAnnoConfig instanceof CacheInvalidateAnnoConfig) || (cacheAnnoConfig instanceof CacheUpdateAnnoConfig)) {
cache = cacheManager.getCache(cacheAnnoConfig.getArea(), cacheAnnoConfig.getName());
if (cache == null) {
CachedAnnoConfig cac = configMap.getByCacheName(cacheAnnoConfig.getArea(), cacheAnnoConfig.getName());
if (cac == null) {
String message = "can't find @Cached definition with area=" + cacheAnnoConfig.getArea()
String message = "can't find cache definition with area=" + cacheAnnoConfig.getArea()
+ " name=" + cacheAnnoConfig.getName() +
", specified in " + cacheAnnoConfig.getDefineMethod();
CacheConfigException e = new CacheConfigException(message);
logger.error("Cache operation aborted because can't find @Cached definition", e);
logger.error("Cache operation aborted because can't find cached definition", e);
return null;
}
cache = createCacheByCachedConfig(cac, invokeContext);
}
cacheAnnoConfig.setCache(cache);
}
cacheAnnoConfig.setCache(cache);
return cache;
}

Expand Down

0 comments on commit dcd20f4

Please sign in to comment.