public class Cache extends OutputFamily
The <o:cache>
component allows to cache a fragment of rendered markup. The first
request for a page that has this component on it will cause this markup to be put into the cache. Then
for subsequent requests the cached content is used directly and none of the components, backing beans
and services that were used to generate this content in the first place will be consulted.
Caching can take place in application scope, or in session scope. For individual fragments a time can be specified for which the cached content is valid. After this time is elapsed, the very first request to the page containing the cache component in question will cause new content to be rendered and put into the cache. A default time can be set per scope in web.xml.
For each scope a maximum capacity can be set. If the capacity for that scope is exceeded, an element will be removed following a least recently used policy (LRU).
Via a cache provider mechanism an alternative cache implementation can be configured in web.xml. The default cache is based on http://code.google.com/p/concurrentlinkedhashmap.
CacheValue
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_TYPE |
static String |
DEFAULT_SCOPE |
static String |
END_CONTENT_MARKER |
static String |
START_CONTENT_MARKER |
static String |
VALUE_SET |
COMPONENT_FAMILY
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
Constructor and Description |
---|
Cache() |
Modifier and Type | Method and Description |
---|---|
void |
encodeChildren(FacesContext context) |
Object |
getCacheAttribute(FacesContext context,
String name)
Gets a named attribute associated with the main cache entry this component is using to store
the rendering of its child components.
|
String |
getKey() |
String |
getScope() |
Integer |
getTime() |
Boolean |
isDisabled()
Returns whether this cache is disabled.
|
Boolean |
isReset() |
Boolean |
isUseBuffer() |
protected boolean |
isVisitable(VisitContext visitContext) |
void |
setCacheAttribute(FacesContext context,
String name,
Object value)
Sets a named attribute associated with the main cache entry this component is using to store
the rendering of its child components.
|
void |
setDisabled(Boolean disabled)
Sets whether this cache is disabled.
|
void |
setKey(String keyValue) |
void |
setReset(Boolean resetValue) |
void |
setScope(String scopeValue) |
void |
setTime(Integer timeValue) |
void |
setUseBuffer(Boolean useBufferValue) |
getFamily, getRendersChildren
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
public static final String COMPONENT_TYPE
public static final String VALUE_SET
public static final String DEFAULT_SCOPE
public static final String START_CONTENT_MARKER
public static final String END_CONTENT_MARKER
public void encodeChildren(FacesContext context) throws IOException
encodeChildren
in class UIComponentBase
IOException
public Object getCacheAttribute(FacesContext context, String name)
context
- the current FacesContextname
- name of the attribute to retrieve a value forpublic void setCacheAttribute(FacesContext context, String name, Object value)
context
- the current FacesContextname
- name of the attribute under which the value is storedvalue
- the value that is to be storedprotected boolean isVisitable(VisitContext visitContext)
isVisitable
in class UIComponent
public String getKey()
public void setKey(String keyValue)
public String getScope()
public void setScope(String scopeValue)
public Integer getTime()
public void setTime(Integer timeValue)
public Boolean isUseBuffer()
public void setUseBuffer(Boolean useBufferValue)
public Boolean isReset()
public void setReset(Boolean resetValue)
public Boolean isDisabled()
public void setDisabled(Boolean disabled)
disabled
- Whether this cache is disabled.Copyright © 2012–2014 OmniFaces. All rights reserved.