public abstract class TimeToLiveCache extends Object implements Cache
Modifier | Constructor and Description |
---|---|
protected |
TimeToLiveCache(Integer defaultTimeToLive) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the entire cache
|
String |
get(String key)
Gets a value from the cache
|
Serializable |
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 cache
|
void |
put(String key,
String value)
Stores a value in the cache
|
void |
put(String key,
String value,
int timeToLive)
Stores a value in the cache
|
void |
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 cache
|
void |
remove(String key)
Removes a value from the cache
|
protected void |
setCacheStore(Map<String,CacheEntry> cacheStore) |
protected TimeToLiveCache(Integer defaultTimeToLive)
public String get(String key)
Cache
public Serializable getObject(String key)
Cache
public void put(String key, String value)
Cache
public void put(String key, String value, int timeToLive)
Cache
put
in interface Cache
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 to
Cache.get(String)
should return null.public void putObject(String key, Serializable value, int timeToLive)
Cache
putObject
in interface Cache
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 to
Cache.get(String)
should return null.public void putAttribute(String key, String name, Serializable value, int timeToLive)
Cache
putAttribute
in interface Cache
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.public Serializable getAttribute(String key, String name)
Cache
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.
getAttribute
in interface Cache
key
- key that identifies the first level cache entryname
- name of the attribute in the second levelpublic void remove(String key)
Cache
public void clear()
Cache
protected void setCacheStore(Map<String,CacheEntry> cacheStore)
Copyright © 2012–2021 OmniFaces. All rights reserved.