@ Override public @ Nullable BinaryResource getResource ( final CacheKey key ) { String resourceId = null ; SettableCacheEvent cacheEvent = SettableCacheEvent . obtain ( ) . setCacheKey ( key ) ; try { synchronized ( mLock ) { BinaryResource resource = null ; List < String > resourceIds = CacheKeyUtil . getResourceIds ( key ) ; for ( int i = 0 ; i < resourceIds . size ( ) ; i ++ ) { resourceId = resourceIds . get ( i ) ; cacheEvent . setResourceId ( resourceId ) ; resource = mStorage . getResource ( resourceId , key ) ; if ( resource != null ) { break ; } } if ( resource == null ) { mCacheEventListener . onMiss ( cacheEvent ) ; mResourceIndex . remove ( resourceId ) ; } else { mCacheEventListener . onHit ( cacheEvent ) ; mResourceIndex . add ( resourceId ) ; } return resource ; } } catch ( IOException ioe ) { mCacheErrorLogger . logError ( CacheErrorLogger . CacheErrorCategory . GENERIC_IO , TAG , "getResource" , ioe ) ; cacheEvent . setException ( ioe ) ; mCacheEventListener . onReadException ( cacheEvent ) ; return null ; } finally { cacheEvent . recycle ( ) ; } }
Retrieves the file corresponding to the mKey if it is in the cache . Also touches the item thus changing its LRU timestamp . If the file is not present in the file cache returns null .