Custom JSP taglib. Lets you cache information in memory. How does it work?
The main tag is Cache. This taglib requests data fron cache (by the key). In case of
success tag prints (outputs) cached data. Otherwise tag evaluates own body, prints it and saves in the cache.
So for the next request it could be obtained from the cache. If cache does not exist it will be created here.
Here is an idea:
<html> <%@ taglib uri="taglib.tld" prefix="c" %> <c:Cache id="A" scope="application" key="k1"> <%=new java.util.Date()%> </c:Cache> </html> You will get the once calculated time in the subsequential requests. Tag getCache lets you simply request data from cache (without putting them in). Also you can directly remove data from cache. You can cache data on the global (application) level or per user (session scope). Also in your application you can have more than one cache, each of them will be described by the own unique id. Each cache has got a limited size (50 records) and supports LRU (Least Recently Used) filling scheme. So the old records will be automatically replaced with the newest on case of overloading. Tags are: Cache. Body tag caches data or gets them from LRU cache. Attributes are: 1) id - describes an unique id for your cache
getCache. Body tag requests data from cache. Tag prints data or saves them in the page scope variable (type is java.lang.String). Otherwise (no cache or data in cache) tag's body will be executed. Attributes are: 1) id - describes an unique id for your cache
remove. Tag removes data from cache. Attributes are: 1) id - describes an unique id for your cache
clear. Tag removes all data from cache. Attributes are: 1) id - describes an unique id for your cache
for downloading: Library: lrucachetag.jar Description: taglib.tld See also Coldtags suite - the largest collection of custom JSP tags.
|
Also in Coldtags:
|