if (cache == null) {
System.out.println("No cache");
log
.warn("FLV cache is null, an NPE may be thrown. To fix your code, ensure a cache is set via Spring or by the following: setCache(NoCacheImpl.getInstance())");
}
ICacheable ic = cache.get(fileName);
// look in the cache before reading the file from the disk
if (null == ic || (null == ic.getByteBuffer())) {
if (file.exists()) {
if (log.isDebugEnabled()) {
log.debug("File size: " + file.length());
}
reader = new FLVReader(file, generateMetadata);
// get a ref to the mapped byte buffer
fileData = reader.getFileData();
// offer the uncached file to the cache
if (fileData != null && cache.offer(fileName, fileData)) {
if (log.isDebugEnabled()) {
log.debug("Item accepted by the cache: " + fileName);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Item will not be cached: " + fileName);
}
}
} else {
log.info("Creating new file: " + file);
file.createNewFile();
}
} else {
fileData = ByteBuffer.wrap(ic.getBytes());
reader = new FLVReader(fileData, generateMetadata);
}
return reader;
}