I have java spring boot application. I want to use cache for frequently read data. For this i included the following dependencies in my jar
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
I have also used the @EnableCaching annotation
@EnableCaching
public class SpringBootConfig {
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootConfig.class, args);
}
}
Used @Cacheable annotation with the function that return the data i want to cache
@Cacheable(value = "country",key = "'countryCache'+#countryCode")
private Country getCountry(String countryCode) {
return new Country(countryCode);
}
But I am still not able to cache the data. Is there anything that i am missing?