private List < Entity > findAllBatch ( List < Object > batch ) { String entityId = getEntityType ( ) . getId ( ) ; EntityType entityType = getEntityType ( ) ; List < Object > missingIds = batch . stream ( ) . filter ( id -> ! l1Cache . get ( entityId , id , entityType ) . isPresent ( ) ) . collect ( toList ( ) ) ; Map < Object , Entity > missingEntities = delegate ( ) . findAll ( missingIds . stream ( ) ) . collect ( toMap ( Entity :: getIdValue , e -> e ) ) ; return batch . stream ( ) . map ( id -> l1Cache . get ( entityId , id , getEntityType ( ) ) . map ( CacheHit :: getValue ) . orElse ( missingEntities . get ( id ) ) ) . collect ( toList ( ) ) ; }
Looks up the Entities for a List of entity IDs . Those present in the cache are returned from cache . The missing ones are retrieved from the decoratedRepository .