-`Suppliers.memoizeWithExpiration` is also straight forward. It allows us to memoize a value from a given `Supplier` but have it update anytime we exceed the expiration time. This is a great caching mechanism for any data you know changes infrequently. A minor drawback is if the operation is expensive you may see a hiccup every time the object needs to be reloaded. Often times this is not a major concern. If it is an issue you can investigate refreshing the object asynchronously with a background thread. `Suppliers.memoizeWithExpiration` is used to cache the scraped results for our [HTML / CSS Themes](https://www.stubbornjava.com/best-selling-html-css-themes-and-website-templates) page and can be seen in the [Web scraping in Java with jsoup and OkHttp](/posts/web-scraping-in-java-using-jsoup-and-okhttp#theme-service-layer). |
0 commit comments