Package org.redisson.spring.cache
Class CacheConfig
java.lang.Object
org.redisson.spring.cache.CacheConfig
Cache config object used for Spring cache configuration.
- Author:
- Nikita Koksharov
-
Constructor Summary
ConstructorsConstructorDescriptionCreates config object withttl = 0andmaxIdleTime = 0.CacheConfig(long ttl, long maxIdleTime) Creates config object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(org.redisson.api.map.event.MapEntryListener listener) listener will invoke if one of the ttl,maxIdleTime,maxSize is set listener Is one of the following implementations: EntryCreatedListener EntryExpiredListener EntryRemovedListener EntryUpdatedListenerstatic Map<String, ? extends CacheConfig> Read config objects stored in YAML format fromFilestatic Map<String, ? extends CacheConfig> fromYAML(InputStream inputStream) Read config objects stored in YAML format fromInputStreamstatic Map<String, ? extends CacheConfig> Read config objects stored in YAML format fromReaderstatic Map<String, ? extends CacheConfig> Read config objects stored in YAML format fromStringstatic Map<String, ? extends CacheConfig> Read config objects stored in YAML format fromURLorg.redisson.api.EvictionModeList<org.redisson.api.map.event.MapEntryListener> longintlonggetTTL()setEvictionMode(org.redisson.api.EvictionMode evictionMode) Set the eviction mode of the map.voidsetListeners(List<org.redisson.api.map.event.MapEntryListener> listeners) voidsetMaxIdleTime(long maxIdleTime) Set max idle time for key\value entry in milliseconds.voidsetMaxSize(int maxSize) Set max size of map.voidsetTTL(long ttl) Set time to live for key\value entry in milliseconds.toString()static StringtoYAML(Map<String, ? extends CacheConfig> config) Convert current configuration to YAML format
-
Constructor Details
-
CacheConfig
public CacheConfig()Creates config object withttl = 0andmaxIdleTime = 0. -
CacheConfig
public CacheConfig(long ttl, long maxIdleTime) Creates config object.- Parameters:
ttl- - time to live for key\value entry in milliseconds. If0then time to live doesn't affect entry expiration.maxIdleTime- - max idle time for key\value entry in milliseconds.if
maxIdleTimeandttlparams are equal to0then entry stores infinitely.
-
-
Method Details
-
getTTL
public long getTTL() -
setTTL
public void setTTL(long ttl) Set time to live for key\value entry in milliseconds.- Parameters:
ttl- - time to live for key\value entry in milliseconds. If0then time to live doesn't affect entry expiration.
-
getMaxSize
public int getMaxSize() -
setMaxSize
public void setMaxSize(int maxSize) Set max size of map. Superfluous elements are evicted using LRU algorithm.- Parameters:
maxSize- - max size If0the cache is unbounded (default).
-
getEvictionMode
public org.redisson.api.EvictionMode getEvictionMode() -
setEvictionMode
Set the eviction mode of the map. Superfluous elements are evicted using LRU or LFU algorithm.- Parameters:
evictionMode- - eviction mode (LRU, LFU)- Returns:
-
getMaxIdleTime
public long getMaxIdleTime() -
setMaxIdleTime
public void setMaxIdleTime(long maxIdleTime) Set max idle time for key\value entry in milliseconds.- Parameters:
maxIdleTime- - max idle time for key\value entry in milliseconds. If0then max idle time doesn't affect entry expiration.
-
addListener
public void addListener(org.redisson.api.map.event.MapEntryListener listener) listener will invoke if one of the ttl,maxIdleTime,maxSize is set listener Is one of the following implementations: EntryCreatedListener EntryExpiredListener EntryRemovedListener EntryUpdatedListener- Parameters:
listener- listener
-
setListeners
-
getListeners
-
fromYAML
Read config objects stored in YAML format fromString- Parameters:
content- of config- Returns:
- config
- Throws:
IOException- error
-
fromYAML
public static Map<String,? extends CacheConfig> fromYAML(InputStream inputStream) throws IOException Read config objects stored in YAML format fromInputStream- Parameters:
inputStream- of config- Returns:
- config
- Throws:
IOException- error
-
fromYAML
Read config objects stored in YAML format fromFile- Parameters:
file- of config- Returns:
- config
- Throws:
IOException- error
-
fromYAML
Read config objects stored in YAML format fromURL- Parameters:
url- of config- Returns:
- config
- Throws:
IOException- error
-
fromYAML
Read config objects stored in YAML format fromReader- Parameters:
reader- of config- Returns:
- config
- Throws:
IOException- error
-
toYAML
Convert current configuration to YAML format- Parameters:
config- map- Returns:
- yaml string
- Throws:
IOException- error
-
toString
-