if (!entry.isSoftExpired()) {
return entry; //fresh hit
} else {
//soft expired - refresh needed
logger.debug("Soft expired " + cacheKey);
RefreshMode mode = request.getRefreshMode();
if (mode == RefreshMode.BLOCK) {
//logger.debug("Sync refresh start " + cacheKey);
return refresh(cacheKey, request);
} else if (mode == RefreshMode.ASYNC || mode == RefreshMode.RETURN) {
asyncRefresh(cacheKey, request); //start asynchronous refresh
logger.debug("Soft expired value returned " + cacheKey);
return entry; //return soft expired value
} else if (mode == RefreshMode.SCHEDULED) {
if (scheduled.get(cacheKey) == null) {
asyncRefresh(cacheKey, request); //start asynchronous refresh
addScheduled(cacheKey, request); //register as scheduled
}
logger.debug("Soft expired value returned " + cacheKey);
return entry; //return soft expired value
} else {
throw new IllegalArgumentException("Unknown RefreshMode " + mode);
}
}
} else { //cache miss - we have nothing
RefreshMode mode = request.getRefreshMode();
if (mode == RefreshMode.BLOCK || mode == RefreshMode.RETURN) {
return refresh(cacheKey, request);
} else if (mode == RefreshMode.ASYNC) {
asyncRefresh(cacheKey, request);
return null;