Skip to content

Commit

Permalink
fix duplicated statistic of load count in method cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
areyouok committed Mar 16, 2018
1 parent cb428b5 commit d70566c
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,16 @@ private static Object invokeWithCached(CacheInvokeContext context)
return loadAndCount(context, cache, key);
}

CacheLoader loader = (k) -> loadAndCount(context, cache, key);
try {
Object result = cache.computeIfAbsent(key, (k) -> {
try {
return loader.load(k);
return invokeOrigin(context);
} catch (Throwable e) {
throw new CacheInvokeException(e.getMessage(), e);
}
});
if (cache instanceof CacheHandlerRefreshCache) {
((CacheHandlerRefreshCache) cache).addOrUpdateRefreshTask(key, loader);
((CacheHandlerRefreshCache) cache).addOrUpdateRefreshTask(key, (unusedKey) -> invokeOrigin(context));
}
return result;
} catch (CacheInvokeException e) {
Expand Down

0 comments on commit d70566c

Please sign in to comment.