- 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 protectedTimeToLiveCache(Integer defaultTimeToLive)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the entire cacheStringget(String key)Gets a value from the cacheSerializablegetAttribute(String key, String name)Gets a named attribute from the cache entry identified by the key parameter.SerializablegetObject(String key)Gets a value from the cachevoidput(String key, String value)Stores a value in the cachevoidput(String key, String value, int timeToLive)Stores a value in the cachevoidputAttribute(String key, String name, Serializable value, int timeToLive)Stores a named attribute in the cache entry identified by the key parameter.voidputObject(String key, Serializable value, int timeToLive)Stores a value in the cachevoidremove(String key)Removes a value from the cacheprotected voidsetCacheStore(Map<String,CacheEntry> cacheStore)
-
-
-
Constructor Detail
-
TimeToLiveCache
protected TimeToLiveCache(Integer defaultTimeToLive)
-
-
Method Detail
-
get
public String get(String key)
Description copied from interface:CacheGets a value from the cache
-
getObject
public Serializable getObject(String key)
Description copied from interface:CacheGets a value from the cache
-
put
public void put(String key, String value)
Description copied from interface:CacheStores a value in the cache
-
put
public void put(String key, String value, int timeToLive)
Description copied from interface:CacheStores a value in the cache- Specified by:
putin 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:CacheStores a value in the cache- Specified by:
putObjectin 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:CacheStores a named attribute in the cache entry identified by the key parameter.- Specified by:
putAttributein 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:CacheGets 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:
getAttributein 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:CacheRemoves a value from the cache
-
clear
public void clear()
Description copied from interface:CacheClears the entire cache
-
setCacheStore
protected void setCacheStore(Map<String,CacheEntry> cacheStore)
-
-