public class CmsFlexCacheKey extends java.lang.Object
It has a lot of variables that are directly accessed (which isn't good style, I know) to avoid method calling overhead (a cache is about speed, isn't it :).
Constructor and Description |
---|
CmsFlexCacheKey(java.lang.String resourcename,
java.lang.String cacheDirectives,
boolean online)
This constructor is used when building a cache key from set of cache directives.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getKeyName(java.lang.String resourcename,
boolean online)
Calculates the cache key name that is used as key in
the first level of the FlexCache.
|
protected java.lang.String |
getResource()
Returns the resource.
|
protected long |
getTimeout()
Returns the timeout.
|
protected java.lang.String |
getVariation()
Returns the variation.
|
boolean |
hadParseError()
This flag is used to indicate that a parse error had
occurred, which can happen if the cache directives String
passed to the constructor using the response is
not build according to the Flex cache language syntax.
|
java.lang.String |
matchRequestKey(CmsFlexRequestKey key)
Compares this key to the other key passed as parameter,
from comparing the two keys, a variation String is constructed.
|
protected void |
setVariation(java.lang.String variation)
Sets the variation.
|
java.lang.String |
toString() |
public CmsFlexCacheKey(java.lang.String resourcename, java.lang.String cacheDirectives, boolean online)
These directives are attached to the properties of the requested resource on a property called "cache". The value of this poperty that is passed in this constructor as "cacheDirectives" is parsed to build the keys data structure.
In case a parsing error occures, the value of this key is set to "cache=never", and the hadParseError() flag is set to true. This is done to ensure that a valid key is always constructed with the constructor.
resourcename
- the full name of the resource including site rootcacheDirectives
- the cache directives of the resource (value of the property "cache")online
- must be true for an online resource, false for offline resourcespublic static java.lang.String getKeyName(java.lang.String resourcename, boolean online)
resourcename
- the full name of the resource including site rootonline
- must be true for an online resource, false for offline resourcespublic boolean hadParseError()
public java.lang.String matchRequestKey(CmsFlexRequestKey key)
This method is the "heart" of the key matching process.
The assumtion is that this key should be the one constructed for the response, while the parameter key should have been constructed from the request.
A short example how this works: If the cache key is "cache=user" and the request is done from a guest user the constructed variation will be "user=(guest)".
key
- the key to match this key withpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
protected java.lang.String getResource()
protected long getTimeout()
protected java.lang.String getVariation()
protected void setVariation(java.lang.String variation)
variation
- the variation to set