- java.lang.Object
-
- org.omnifaces.util.cache.TimeToLiveCache
-
- All Implemented Interfaces:
Serializable
,Cache
- Direct Known Subclasses:
DefaultCache
public abstract class TimeToLiveCache extends Object implements Cache
Base class that can be used by Map based caches that don't support time to live semantics and arbitrary attributes natively.- Since:
- 1.1
- Author:
- Arjan Tijms
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TimeToLiveCache(Integer defaultTimeToLive)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the entire cacheString
get(String key)
Gets a value from the cacheSerializable
getAttribute(String key, String name)
Gets a named attribute from the cache entry identified by the key parameter.Serializable
getObject(String key)
Gets a value from the cachevoid
put(String key, String value)
Stores a value in the cachevoid
put(String key, String value, int timeToLive)
Stores a value in the cachevoid
putAttribute(String key, String name, Serializable value, int timeToLive)
Stores a named attribute in the cache entry identified by the key parameter.void
putObject(String key, Serializable value, int timeToLive)
Stores a value in the cachevoid
remove(String key)
Removes a value from the cacheprotected void
setCacheStore(Map<String,CacheEntry> cacheStore)
-
-
-
Constructor Detail
-
TimeToLiveCache
protected TimeToLiveCache(Integer defaultTimeToLive)
-
-
Method Detail
-
get
public String get(String key)
Description copied from interface:Cache
Gets a value from the cache
-
getObject
public Serializable getObject(String key)
Description copied from interface:Cache
Gets a value from the cache
-
put
public void put(String key, String value)
Description copied from interface:Cache
Stores a value in the cache
-
put
public void put(String key, String value, int timeToLive)
Description copied from interface:Cache
Stores a value in the cache- Specified by:
put
in interfaceCache
- Parameters:
key
- the key under which a value is to be storedvalue
- the value that is to be storedtimeToLive
- the amount of time in seconds for which the cached value is valid from the time it's being added to the cache. It's provider specific whether the cache implementation will actually remove (evict) the entry after this time has elapsed or will only perform a check upon accessing the cache entry. Whatever method the implementation chooses; after this time is elapsed a call toCache.get(String)
should return null.
-
putObject
public void putObject(String key, Serializable value, int timeToLive)
Description copied from interface:Cache
Stores a value in the cache- Specified by:
putObject
in interfaceCache
- Parameters:
key
- the key under which a value is to be storedvalue
- the value that is to be storedtimeToLive
- the amount of time in seconds for which the cached value is valid from the time it's being added to the cache. It's provider specific whether the cache implementation will actually remove (evict) the entry after this time has elapsed or will only perform a check upon accessing the cache entry. Whatever method the implementation chooses; after this time is elapsed a call toCache.get(String)
should return null.
-
putAttribute
public void putAttribute(String key, String name, Serializable value, int timeToLive)
Description copied from interface:Cache
Stores a named attribute in the cache entry identified by the key parameter.- Specified by:
putAttribute
in interfaceCache
- Parameters:
key
- key that identifies the first level cache entryname
- name of the attribute in the second levelvalue
- value associated with the {key, name} hierarchy.timeToLive
- the amount of time in seconds for which the cached value is valid. Only used when there's no first level entry yet.
-
getAttribute
public Serializable getAttribute(String key, String name)
Description copied from interface:Cache
Gets a named attribute from the cache entry identified by the key parameter.This in effect implements a 2-level multi-map, which the single main value stored in the first level, and the optional attributes stored in the second level.
- Specified by:
getAttribute
in interfaceCache
- Parameters:
key
- key that identifies the first level cache entryname
- name of the attribute in the second level- Returns:
- the value associated with the {key, name} hierarchy.
-
remove
public void remove(String key)
Description copied from interface:Cache
Removes a value from the cache
-
clear
public void clear()
Description copied from interface:Cache
Clears the entire cache
-
setCacheStore
protected void setCacheStore(Map<String,CacheEntry> cacheStore)
-
-