I am new to Spring boot caching, as per my requirement i want to use JCS with spring boot(rest api). I have searched over the google but, haven't got much information about it.
There is info available with java class. Does any one knows how to use it or any related tutorial or information.
This might be the opinion based question. But it is much needed.
public static void main(String[] args) {
// Initialize the JCS object and get an instance of the default cache region
try {
JCS cache = JCS.getInstance("default");
String key = "key0";
String value = "value0";
cache.put(key, value);
cache.put("vasu","dev");
} catch (CacheException e) {
e.printStackTrace();
}
}
As far as caching with spring boot is concerned, spring supports the following cache providers, as it has been mentioned in the following link.
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-caching.html
To quote, It says
I will suggest to use Ehcache, you can check more details on Ehcache with Spring framework in the below link. https://www.baeldung.com/spring-cache-tutorial
If you are only interested about JCS, then refer below the link to have an understanding.
https://codyburleson.com/quick-and-simple-caching-with-apache-commons-jcs/
In case pf Spring boot, I will suggest to create class and wrap JCS inside that class so that you can wire in any class so that you can abstract away the JCS implementation details. I provide below outline.
@Autowired CacheUpdater cacheUpdate;
in the method, you can write like this,
public void someMethod(... params) { cacheUpdater.update(key,value) }
It is not necessary that, you have to have a method called update(), you can create any method and it should internally call JCS to put the key and value in cache.