Object
HttpSessionBindingListener, Serializable
An object to help with caching a Node or a array of Nodes.
This object can placed anywhere for use as a cache. For convience, the
getNodeCache method can be used with a JSP
PageContext to create and utilize ContentCaches.
Additionally, this is what the SearchTag and
GetNodeTag tags use when useCache="true".>
Object
NodeCache
EventListener, HttpSessionBindingListener, Serializable
Field Summary |
public static final |
|
protected |
|
Constructor Summary |
|
Method Summary |
public static void |
|
public synchronized void |
|
public static |
|
public synchronized long |
|
public synchronized |
|
public synchronized long |
|
public static |
|
public synchronized | |
public static |
|
public static |
|
public synchronized | |
public synchronized int |
|
public static |
|
public synchronized | |
public static void |
|
public static void |
|
public synchronized void | |
public synchronized void | |
public void |
|
public void |
|
Methods from class java.lang. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods from interface javax.servlet.http. |
valueBound, valueUnbound |
Field Detail |
public static final String DEF_CACHE_NAME
When the NodeCache.getNodeCache(PageContext, int, boolean) method is used,
this is the name which will used.
protected Map nodeCache
Constructor Detail |
public NodeCache()
Method Detail |
public static void bindToSession(Bind a NodeCache to an HttpSession.NodeCachecache,HttpSessionsession)
This will use DEF_CACHE_NAME as the session
attribute name for the cache.
public synchronized void clear()Clear the entire cache.
public staticGet a scoped attribute correctly from the JSP page context.ObjectgetAttribute(PageContextctx,Stringname, int scope)
public synchronized long getCachedTime(String id)
Get the UTC time (in ms.) of when the nodes at id were cached.
public synchronized List getCacheIds()
Get an unordered list of all the cache ids.
Since the keys will all be Strings, this can be sorted with
Collections.sort(List).
public synchronized long getCacheSize()Get the total number of nodes objects cached (across all ids).
public staticGet a NodeCache from an HttpSession.NodeCachegetFromSession(HttpSessionsession, boolean create)
This will retrieve the cache from the session attribute named
DEF_CACHE_NAME. If that is set and is not a
NodeCache will be removed.
public synchronizedCheck the cache for the node.NodegetNode(Stringid, long timeout)
Getting a node from the cache does not update its time in terms of
a timeout. Only using the NodeCache.update(String, Node[]) method to update the cache
will do that.
public staticGet a NodeCache from the specified JSP context.NodeCachegetNodeCache(PageContextctx, int scope, boolean create)
This will retrieve the NodeCache from the JSP context based upon
the specified scope at the attribute named
DEF_CACHE_NAME. If that is set and is not a
NodeCache will be removed.
public staticGet a NodeCache from the specified JSP context.NodeCachegetNodeCache(PageContextctx,StringscopeStr, boolean create)
If scopeStr is "application", then PageContext.APPLICATION_SCOPE is used; if scopeStr is "page", then PageContext.PAGE_SCOPE is used; if scopeStr is "request", then PageContext.REQUEST_SCOPE is used; if scopeStr is "session", then PageContext.SESSION_SCOPE is used; otherwise, scopeStr is passed to ctx.getAttributesScope() which will determine the scope to use.
public synchronizedCheck the cache for the nodes.Node[] getNodes(Stringid, long timeout)
Getting nodes from the cache does not update its time in terms of
a timeout. Only using the NodeCache.update(String, Node[]) method to update the cache
will do that.
public synchronized int getNumCacheIds()Get the number of cache ids in the cache.
public static String getScopeName(int scope)
Get the scope name based upon the scope id.
public synchronizedClear a particular entry from the cache.Node[] remove(Stringid)
public static void removeAttribute(Remove a scoped attribute correctly from the JSP page context.PageContextctx,Stringname, int scope)
public static void setAttribute(Set a scoped attribute correctly in the JSP page context.PageContextctx,Stringname,Objectval, int scope)
public synchronized void update(Update the cache with the nodes.Stringid,Node[] nodes)
This can be used for new or existing nodes in the cache.
public synchronized void update(Update the cache with the Node.Stringid,Nodenode)
This can be used for new or existing Nodes in the cache.
public void valueBound(HttpSessionBindingEvent evt)
Called when we're bound into an HttpSession.
public void valueUnbound(HttpSessionBindingEvent evt)
Called when we're unbound from an HttpSession, and clears the cache.
Related Topics