Package lazyj
Class CachingStructure
java.lang.Object
lazyj.CachingStructure
- All Implemented Interfaces:
- Comparable<CachingStructure>
Holding class for page cache entries
- Since:
- 2006-10-04
- Author:
- costing
- 
Field SummaryFieldsModifier and TypeFieldDescriptionintNumber of accesses to this cache entry.final longThe time when this cache entry was generatedfinal longLifetime, in milliseconds, from the moment of its registration in the PageCache.final StringContent type (defaults to text/html)final StringUnique key to access this content
- 
Method SummaryModifier and TypeMethodDescriptionintFor sorting first by the number of accesses then by the key, then by expiration timebooleanWhether or not two objects are in fact the same structurebyte[]Get the contents.intGet the memory footprint of the cached content.inthashCode()Rewrite the default hash distribution methodintlength()Get the size of the cached content.voidsetHeaders(javax.servlet.http.HttpServletResponse response) Set the proper HTTP headers for this cached contenttoString()Overriden toString() produces a nicer HTML output, for web statistics
- 
Field Details- 
lGeneratedpublic final long lGeneratedThe time when this cache entry was generated
- 
lifetimepublic final long lifetimeLifetime, in milliseconds, from the moment of its registration in the PageCache.
- 
sKeyUnique key to access this content
- 
iAccessespublic int iAccessesNumber of accesses to this cache entry.
- 
sContentTypeContent type (defaults to text/html)
 
- 
- 
Method Details- 
getContentpublic byte[] getContent()Get the contents.- Returns:
- the contents of the cache
 
- 
setHeaderspublic void setHeaders(javax.servlet.http.HttpServletResponse response) Set the proper HTTP headers for this cached content- Parameters:
- response- object to set the headers on
 
- 
getContentAsString- Returns:
- the String representation of this cache entry. Useful for JSPs where we anyway have to convert to String. This method caches the returned value so it's more efficient to use it instead
         of new String(getContent())each time
 
- 
compareToFor sorting first by the number of accesses then by the key, then by expiration time- Specified by:
- compareToin interface- Comparable<CachingStructure>
- Parameters:
- cs- object to compare to
- Returns:
- sort order
 
- 
equalsWhether or not two objects are in fact the same structure
- 
hashCodepublic int hashCode()Rewrite the default hash distribution method
- 
lengthpublic int length()Get the size of the cached content. Beware that the actual content might be compressed in memory to save space.- Returns:
- size of the cached data entry
 
- 
getRealSizepublic int getRealSize()Get the memory footprint of the cached content. Might be less than the original size if a compression was applied.- Returns:
- original content size
 
- 
toStringOverriden toString() produces a nicer HTML output, for web statistics
 
-