I'm using spring cache with redis implementation, I have following method
@Async
@Cacheable(key = "#id")
public Future<Student> getStudent(String id){
Student stu = ...;
return new AsyncResult<>(stu);
}
When I visit the method first time, the data is cached into redis in json format.
but when I visit it the second time, it occurs some error like this:
java.util.concurrent.ExecutionException: org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Cannot construct instance of org.springframework.scheduling.annotation.AsyncResult
(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
[EDIT]
I found a workaround : new a MyAsyncReslt.java which extends AsyncResult and add the NoArgsContructor.