Micronaut Cache

23 Views Asked by At

I need to implement caching in micronaut application on one method. I followed micronaut documentation, below is the link, but it didn't work. Can you please suggest me what we can do or is there any way to work cache. Also I've tried to enable debug logs for cache, but I can't find any config which enables debug logs for micronaut caching.

Documentation Link which I've tried but didn't work - https://guides.micronaut.io/latest/micronaut-cache-gradle-java.html

Below is the method which I need to make cacheable

public HotelDetails hotelDetails(String hotelId) {
        HotelDetails hotelDetailsResponse = null;
        try {
            String accessToken = authenticate();

            String url = buildHotelDetailsUrl(hotelId);
            HttpResponse<ListingResponse> response = webClientConfiguration.getHttpClient(url, ListingResponse.class, accessToken);

            if (response.getStatus().getCode() == 200) {
                Optional<ListingResponse> listingResponseOptional = response.getBody();
                if (listingResponseOptional.isPresent()){
                    ListingResponse guestyListingResponse = listingResponseOptional.get();
                    hotelDetailsResponse = convertHotelDetailsResponse(ListingResponse.getResults());
                }
//
            } else {
                throw new ClientException(ErrorCode.CLIENT_EXCEPTION);
            }
        } catch (Exception e) {
            logger.error("Getting error in hotelDetails function {}", e.getMessage());
            throw new InternalServerException(ErrorCode.INTERNAL_SERVER_EXCEPTION);
        }
        if (hotelDetailsResponse == null) {
            throw new DownStreamException(ErrorCode.DOWNSTREAM_EXCEPTION);
        }
        return hotelDetailsResponse;
    }
0

There are 0 best solutions below