public class ExtendedSSMCacheManager extends SSMCacheManager
Cache
. Spring Cache and
CacheManager doesn't support configuring expiration time per method (there is no dedicated parameter in cache
annotation to pass expiration time). This extension of SSMCacheManager
overcomes this limitation and allow to
pass expiration time as a part of cache name. To define custom expiration on method as a cache name use concatenation
of specific cache name, separator and expiration e.g.
public class UserDAO { // cache name: userCache, expiration: 300s @Cacheable("userCache#300") public User getUser(String name) { } }An expiration time is specified in seconds. They can be set from 0, meaning "never expire", to 30 days (60*60*24*30). Any time higher than 30 days is interpreted as a unix timestamp date.
Constructor and Description |
---|
ExtendedSSMCacheManager() |
Modifier and Type | Method and Description |
---|---|
SSMCache |
getCache(String name) |
char |
getSeparator() |
void |
setSeparator(char separator)
Char that separates cache name and expiration time, default: #.
|
addCache, afterPropertiesSet, getCacheNames, getCaches, removeCache, setCaches
public SSMCache getCache(String name)
getCache
in interface org.springframework.cache.CacheManager
getCache
in class SSMCacheManager
public char getSeparator()
public void setSeparator(char separator)
separator
- Copyright © 2019. All rights reserved.