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 Summary
FieldsModifier and TypeFieldDescriptionint
Number of accesses to this cache entry.final long
The time when this cache entry was generatedfinal long
Lifetime, in milliseconds, from the moment of its registration in the PageCache.final String
Content type (defaults to text/html)final String
Unique key to access this content -
Method Summary
Modifier and TypeMethodDescriptionint
For sorting first by the number of accesses then by the key, then by expiration timeboolean
Whether or not two objects are in fact the same structurebyte[]
Get the contents.int
Get the memory footprint of the cached content.int
hashCode()
Rewrite the default hash distribution methodint
length()
Get the size of the cached content.void
setHeaders
(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
-
lGenerated
public final long lGeneratedThe time when this cache entry was generated -
lifetime
public final long lifetimeLifetime, in milliseconds, from the moment of its registration in the PageCache. -
sKey
Unique key to access this content -
iAccesses
public int iAccessesNumber of accesses to this cache entry. -
sContentType
Content type (defaults to text/html)
-
-
Method Details
-
getContent
public byte[] getContent()Get the contents.- Returns:
- the contents of the cache
-
setHeaders
public 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
-
compareTo
For sorting first by the number of accesses then by the key, then by expiration time- Specified by:
compareTo
in interfaceComparable<CachingStructure>
- Parameters:
cs
- object to compare to- Returns:
- sort order
-
equals
Whether or not two objects are in fact the same structure -
hashCode
public int hashCode()Rewrite the default hash distribution method -
length
public 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
-
getRealSize
public 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
-
toString
Overriden toString() produces a nicer HTML output, for web statistics
-