CompletableFuture < Boolean > actualRemoveMaxIdleExpireEntry ( K key , V value , long maxIdle , boolean skipLocking ) { CompletableFuture < Boolean > completableFuture = new CompletableFuture <> ( ) ; Object expiringObject = expiring . putIfAbsent ( key , completableFuture ) ; if ( expiringObject == null ) { if ( trace ) { log . tracef ( "Submitting expiration removal for key %s which had maxIdle of %s" , toStr ( key ) , maxIdle ) ; } completableFuture . whenComplete ( ( b , t ) -> expiring . remove ( key , completableFuture ) ) ; try { AdvancedCache < K , V > cacheToUse = skipLocking ? cache . withFlags ( Flag . SKIP_LOCKING ) : cache ; CompletableFuture < Boolean > expired = cacheToUse . removeMaxIdleExpired ( key , value ) ; expired . whenComplete ( ( b , t ) -> { if ( t != null ) { completableFuture . completeExceptionally ( t ) ; } else { completableFuture . complete ( b ) ; } } ) ; return completableFuture ; } catch ( Throwable t ) { completableFuture . completeExceptionally ( t ) ; throw t ; } } else if ( expiringObject instanceof CompletableFuture ) { // This means there was another thread that found it had expired via max idle return ( CompletableFuture < Boolean > ) expiringObject ; } else { // If it wasn't a CompletableFuture we had a lifespan removal occurring so it will be removed for sure return CompletableFutures . completedTrue ( ) ; } }
Method invoked when entry should be attempted to be removed via max idle