public interface Cache extends Serializable
Note that this takes Strings for both key and value since it's not intended as a general cache solution, but is
something specific for the Cache
component which caches rendered output.
Modifier and Type | Method and Description |
---|---|
String |
get(String key)
Gets a value from the cache
|
Object |
getAttribute(String key,
String name)
Gets a named attribute from the cache entry identified by the key parameter.
|
Object |
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,
Object value,
int timeToLive)
Stores a named attribute in the cache entry identified by the key parameter.
|
void |
putObject(String key,
Object value,
int timeToLive)
Stores a value in the cache
|
void |
remove(String key)
Removes a value from the cache
|
String get(String key)
key
- the key under which a value was previously storedObject getObject(String key)
key
- the key under which a value was previously storedvoid put(String key, String value)
key
- the key under which a value is to be storedvalue
- the value that is to be storedvoid putObject(String key, Object value, int timeToLive)
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
get(String)
should return null.void put(String key, String value, int timeToLive)
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
get(String)
should return null.Object getAttribute(String key, String name)
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.
key
- key that identifies the first level cache entryname
- name of the attribute in the second levelvoid putAttribute(String key, String name, Object value, int timeToLive)
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. See putAttribute(String, String, Object, int)
void remove(String key)
key
- the key under which a value is to be storedCopyright © 2012–2016 OmniFaces. All rights reserved.