Cocoon |
|
|
External Cache Invalidator Server interface |
The External Cache Invalidator Class implements a new modality for Cocoon2's
cache System. It provides a new way to invalidate cached pages stored into
Cocoon cache system with a simple external message interpreted by an XSP page.
It mean that you could generate a dynamic page with DBPrism or with an XSP page
and stored it into the Cocoon Cache system, this page will remaind valid into the cache
until an XML message says to this server implementation that the stored page is no
longer valid, a this point Cocoon will generate a new one. This kind of synchronization
is commonly implemented through triggers into the database that provides the information
for the dynamic page. For a practical example of these triggers look at the
CMS Trigger Sections.
|
This interface defines a role for every possible implementation of an External Cache Invalidator Server functionality.
It defines a role for the Avalon roles, and it also needs to modify cocoon.roles file included into cocoon.jar or user.roles file,
here the sample entry.
| | |
|
<role name="org.apache.cocoon.components.cache.Server"
shorthand="cache-server"
default-class="org.apache.cocoon.components.cache.DatabaseServerImpl"/>
| |
| | |
|
DatabaseServerImpl class is a concrete class which implements
the defined contract using HSQL database for storing the cached pages metadata,
other implementation could be added in a short future providing faster implementation
for accessing and invalidating higher amount of cached pages. |
-
public boolean isRegistered(ESIKey key),
Returns true or false if the key argument is register as a Cached Page.
-
public long getCacheablePageKey(ESIKey key),
Returns a long value used by Cocoon's cache system to locate a Cached Page.
-
public void registerCacheablePage(ESIKey key),
Registers a Cached Page, this page is identified by an ESIKey object which holds the
URL for this page, his encoded argument and the long value used by Cocoon's cache
system to identified the cached page.
-
public int removeCacheablePage(String username,
String password,
String URI,
String URIRegExp,
ESIKey key,
int ttl),
Removes a previous cached page identified by the URI path,
the URIRegExp regular expresion and the encoded arguments, it requires
a valid username and password to access to the cache server.
This method do not remove automatically the page, it stores the ESIKey into a queue
of pages to invalidate, this queue is cheked every 1 second by default.
See DatabaseServerImpl section for more details.
ttl (or time-to-live) value is reserved for future use.
URI is a base path for the page(s) to be remove.
URIRegExp is a regular expresion used for matching with the page(s) to remove
| | |
|
Note about URI and URIRegExp:
URI = /p1/p2/p3/ and
URIRegExp = ^/p1/p2/p3/file.htm$ or
URI = / and
URIRegExp = ^/p1/p2/p3/file.htm$
match with the same page /p1/p2/p3/file.htm.
Since the regular expression is done against the set of page objects containing
the common URIPREFIX path prefix, it is obvious that the smaller the set,
the more efficient the invalidation.
| |
| | |
|
-
ROLE,
Defines Avalon Role for this server.
-
NONE, EXTERNAL, NOP,
Used by DBPrismGenerator to identified three kind of cacheability rules.
None means that the page is no cacheable, External means that the page is controled
by the External Cache Invalidator Server and the method generateValidity() will return
an instance of ExternalCacheValidity object, NOP means that the page is cacheable and
will remains in the Cocoon cache during the life of Cocoon instance
(generateValidity() will return an object of type NOPCacheValidity).
-
COPY_ARG_NAME,
Used by the CocoonRequestWrapper to merge the standard servlet http request arguments
with the sitemap arguments.
-
COPY_NO and COPY_YES,
Special values used into Copy-Request-Arguments, false
mean that only pass DBPrismGenerator sitemap parameters, true
mean that all the http arguments and cookies are passed to the DBPrismGenerator.
-
CACHE_CONTROL_ARG_NAME,
Its the name on the sitemap argument that defines the cacheability behaviour
on DBPrismGenerator.
-
CACHE_CONTROL_EXTERNAL, CACHE_CONTROL_NOP, CACHE_CONTROL_NONE,
Values defined for the previous one argument on the sitemap syntax.
|
|
|
|
|
|