Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Spring Redis Annotation for different return types

$
0
0

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

  1. Does @Cacheable annotation auto-serialize the object Student and List of Teacher into the string that will be stored in Redis as value?

  2. What's the relationship between @Cacheable and RedisTemplate? Will @Cacheable use RedisTemplate to read/write data?

  3. 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?

  4. 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){...}


Viewing all articles
Browse latest Browse all 2204

Trending Articles