I have a Cached method that return object of some class. My app is multithreading. When one thread get cached object and process it, another thread also can get and modify this object and first thread has a problem.
@Cacheable(value="MyCache")
Script parse(String scriptText) {
return new MyObject(scriptText);
}
How to configure it that method return a copy of cached object instead of the same object. Or how to serialize method result and deserialize when request a cached value.
I am using Spring Boot with Ehcache.