Class WeatherCache


  • @Technical
    @Bean
    @Singleton
    public class WeatherCache
    extends Object
    Cache of weather forecast data coming from a weather service.
    Author:
    mmoquillon
    • Constructor Detail

      • WeatherCache

        public WeatherCache()
    • Method Detail

      • get

        public final WeatherForecastData get​(String cityId,
                                             Supplier<WeatherForecastData> supplier)
        Gets the weather forecast data from the cache or invokes the specified supplier if no such data are in the cache or if the data is expired. If the supplier is invoked, the returned data is then automatically cached.
        Parameters:
        cityId - the unique identifier of a city.
        supplier - a supplier of WeatherForecastData instance.
        Returns:
        a WeatherForecastData instance.