LiveWebCacheUnavailableException, LiveWebTimeoutException,
IOException {
String url = urlURL.toExternalForm();
RedisValue value = null;
try {
PerfStats.timeStart(PerfStat.RobotsRedis);
if (redisCmds != null) {
value = redisCmds.getValue(url);
}
} catch (LiveWebCacheUnavailableException lw) {
value = null;
} finally {
PerfStats.timeEnd(PerfStat.RobotsRedis);
}
// Use the old liveweb cache, if provided
if (value == null) {
RobotsResult result = loadExternal(urlURL, maxCacheMS, bUseOlder);
PerfStats.timeStart(PerfStat.RobotsRedis);
this.updateCache(result.robots, url, null, result.status, true);
PerfStats.timeEnd(PerfStat.RobotsRedis);
if (result == null || result.status != STATUS_OK) {
throw new LiveDocumentNotAvailableException("Error Loading Live Robots");
}
return new RobotsTxtResource(result.robots);
} else {
if (isExpired(value, url, 0)) {
PerfStats.timeStart(PerfStat.RobotsRedis);
redisCmds.pushKey(UPDATE_QUEUE_KEY, url, MAX_UPDATE_QUEUE_SIZE);
PerfStats.timeEnd(PerfStat.RobotsRedis);
}
String currentRobots = value.value;
if (currentRobots.startsWith(ROBOTS_TOKEN_ERROR)) {
throw new LiveDocumentNotAvailableException("Robots Error: " + currentRobots);
} else if (value.equals(ROBOTS_TOKEN_EMPTY)) {
currentRobots = "";
}
return new RobotsTxtResource(currentRobots);
}