I want to cache the List in redis. Below is the service method for the same:-
@Autowiredprivate RedisTemplate<String, Object> redisTemplate;@Cacheable(value = "notes", key = "#userId")public ResponseEntity<?> getAllNotes(Integer userId) { HashOperations<String, String, Object> hashOperations = redisTemplate.opsForHash(); //Check if the cacheKey contains this userId if (hashOperations.hasKey(cacheKey, userIdAsKey)) { List<NoteResponse> noteResponses = (List<NoteResponse>) hashOperations.get(cacheKey, userIdAsKey); return ResponseEntity.ok(noteResponses); } List<Note> notes = noteRepository.findAllByUserId(userId); List<NoteResponse> noteResponses = Helper.getNoteResponse(notes); hashOperations.put(cacheKey, userIdAsKey, noteResponses); return ResponseEntity.ok(noteResponses);}
but i am getting this exception: java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [org.springframework.http.ResponseEntity]