protected VALUE withCaching ( KEY key , Supplier < VALUE > cacheLoader ) { return getCache ( ) . map ( CachingTemplate :: with ) . < VALUE > map ( template -> template . withCaching ( key , ( ) -> { setCacheMiss ( ) ; return cacheLoader . get ( ) ; } ) ) . orElseGet ( cacheLoader ) ; }
Enables an application service method to optionally apply and use caching to carry out its function .