I am using Spring Redis in my application and I annotated some methods with @Cacheable to cache the result and/or retrieve the result from cache if it exists.
However, the return type of these methods are different. For instance:
@Cacheable(value = "myApp")
public Student getStudentInfo(StudentInput input){...}
@Cacheable(value = "myApp")
public List<Teacher> getStudentInfo(TeacherInput input){...}
My questions
Does @Cacheable annotation auto-serialize the object Student and List of Teacher into the string that will be stored in Redis as value?
What's the relationship between @Cacheable and RedisTemplate? Will @Cacheable use RedisTemplate to read/write data?
If I define some beans with my own RedisTemplate <String, Object> and RedisTemplate <String, List>, how does @Cacheable determine which one to use? Do I need to specify the bean name within @Cacheable(...) config?
How to set up different TTL value within @Cacheable(...)? for example
@Cacheable(value = "myApp", TTL = 100 sec)
public Student getStudentInfo(StudentInput input){...}
@Cacheable(value = "myApp", TTL = 600 sec)
public List<Teacher> getStudentInfo(TeacherInput input){...}