return true;
}
@Override
public void serve(final Sender sender, final HttpServerExchange exchange, final IoCallback completionCallback) {
final DirectBufferCache dataCache = cachingResourceManager.getDataCache();
if(dataCache == null) {
underlyingResource.serve(sender, exchange, completionCallback);
return;
}
final DirectBufferCache.CacheEntry existing = dataCache.get(cacheKey);
final Long length = getContentLength();
//if it is not eligable to be served from the cache
if (length == null || length > cachingResourceManager.getMaxFileSize()) {
underlyingResource.serve(sender, exchange, completionCallback);
return;
}
//it is not cached yet, install a wrapper to grab the data
if (existing == null || !existing.enabled() || !existing.reference()) {
Sender newSender = sender;
final DirectBufferCache.CacheEntry entry;
if (existing == null) {
entry = dataCache.add(cacheKey, length.intValue(), cachingResourceManager.getMaxAge());
} else {
entry = existing;
}
if (entry != null && entry.buffers().length != 0 && entry.claimEnable()) {