Posts

Showing posts from July, 2015

Add Guava Cache to Spring Boot to Cache Method Calls

Image
Add Google Guava Cache to Spring Boot to Cache the Results of Method Calls using Java Config and Spring Annotations If you have a time-intensive method that is slowing down your application and the results of that method don't change very often, it is a good candidate for caching.  This guide will show you how to implement caching in your Spring Boot application using Google Guava cache.   Guava cache is a simple, lightweight in-memory cache that has more configuration options then the default In-Memory Spring Cache.  Guava cache is not for clustered systems, for that you will want to use Hazelcast  http://hazelcast.com/ So if you just need a simple cache but you want more config options such as cache expiration time, then this approach may fit your use case.  Alternatively, you could use EhCache. Full source code references can be found at the bottom of the article. More info on Guava Cache: https://code.google.com/p/guava-libraries/wiki/CachesExplained Mo