public Optional < V > get ( K key ) { if ( cacheIsFull ( ) ) { Entry entry = mMap . get ( key ) ; if ( entry == null ) { return load ( key ) ; } return Optional . ofNullable ( entry . mValue ) ; } Entry result = mMap . compute ( key , ( k , entry ) -> { if ( entry != null ) { entry . mReferenced = true ; return entry ; } Optional < V > value = load ( key ) ; if ( value . isPresent ( ) ) { onCacheUpdate ( key , value . get ( ) ) ; Entry newEntry = new Entry ( key , value . get ( ) ) ; newEntry . mDirty = false ; return newEntry ; } return null ; } ) ; if ( result == null || result . mValue == null ) { return Optional . empty ( ) ; } wakeEvictionThreadIfNecessary ( ) ; return Optional . of ( result . mValue ) ; }
Retrieves a value from the cache loading it from the backing store if necessary .