Spring Cache
Contents
@EnableCaching
@Cachable ({"cache-name-1", "cache-name-2"})
- will first check the cache addresses before actually invoking the method and then caching the result
- if multiple cache used, will return if present in anyone
@CacheEvict(value="cache-name", allEntries=true)
- eviction policy to manage cache size for faster lookup and low memory usage
@CachePut(value="cache-name")
- avoid evicting too much of cache
- selectively entries whenever we alter them
- Cachable will not invoke method if present in cache; CachePut will always? invoke and update in cache
@Caching
for grouping multiple annotations of same type on same method (Java doesn’t allow it)
|
|
@CacheConfig
- class level cache configuration common to all its methods annotated as cache
|
|
Conditional Parameters (all annotations)
- Use SpEL expression
condition="#customer.name=='Tom'"
- based on result after method exec
unless="#result.length()<64"