private @ Nullable PooledByteBuffer readFromDiskCache ( final CacheKey key ) throws IOException { try { FLog . v ( TAG , "Disk cache read for %s" , key . getUriString ( ) ) ; final BinaryResource diskCacheResource = mFileCache . getResource ( key ) ; if ( diskCacheResource == null ) { FLog . v ( TAG , "Disk cache miss for %s" , key . getUriString ( ) ) ; mImageCacheStatsTracker . onDiskCacheMiss ( ) ; return null ; } else { FLog . v ( TAG , "Found entry in disk cache for %s" , key . getUriString ( ) ) ; mImageCacheStatsTracker . onDiskCacheHit ( key ) ; } PooledByteBuffer byteBuffer ; final InputStream is = diskCacheResource . openStream ( ) ; try { byteBuffer = mPooledByteBufferFactory . newByteBuffer ( is , ( int ) diskCacheResource . size ( ) ) ; } finally { is . close ( ) ; } FLog . v ( TAG , "Successful read from disk cache for %s" , key . getUriString ( ) ) ; return byteBuffer ; } catch ( IOException ioe ) { // TODO: 3697790 log failures // TODO: 5258772 - uncomment line below // mFileCache.remove(key); FLog . w ( TAG , ioe , "Exception reading from cache for %s" , key . getUriString ( ) ) ; mImageCacheStatsTracker . onDiskCacheGetFail ( ) ; throw ioe ; } }
Performs disk cache read . In case of any exception null is returned .