You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2007/02/02 16:51:31 UTC
svn commit: r502638 -
/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
Author: cziegeler
Date: Fri Feb 2 07:51:28 2007
New Revision: 502638
URL: http://svn.apache.org/viewvc?view=rev&rev=502638
Log:
Core: Exipres caching pipeline can now cache the content forever (by setting cache-expires
to a negative value).
Modified:
cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java?view=diff&rev=502638&r1=502637&r2=502638
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java Fri Feb 2 07:51:28 2007
@@ -33,6 +33,7 @@
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.ExpiresValidity;
+import org.apache.excalibur.source.impl.validity.NOPValidity;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
@@ -46,6 +47,11 @@
* <parameter name="cache-expires" value="180"/> <!-- Expires in secondes -->
* </map:pipe>
*
+ * The cache-expires parameter controls the period of time for caching the content. A positive
+ * value is a value in seconds, a value of zero means no caching and a negative value means
+ * indefinite caching. In this case, you should use an external mechanism to invalidate the
+ * cache entry.
+ *
* @since 2.1
* @version $Id$
*/
@@ -64,7 +70,7 @@
/** The key used for caching */
protected IdentifierCacheKey cacheKey;
- /** The expires information */
+ /** The expires information. */
protected long cacheExpires;
/** Default value for expiration */
@@ -171,7 +177,7 @@
// internal
if ( this.cachedResponse == null) {
// if we cache, we need an xml serializer
- if ( this.cacheExpires > 0) {
+ if ( this.cacheExpires != 0) {
final XMLConsumer old = this.lastConsumer;
this.xmlSerializer = new XMLByteStreamCompiler();
this.lastConsumer = new XMLTeePipe(this.lastConsumer, this.xmlSerializer);
@@ -229,6 +235,8 @@
this.serializer == this.lastConsumer);
if ( this.cacheExpires > 0) {
this.cacheValidity = new ExpiresValidity(this.cacheExpires*1000);
+ } else if ( this.cacheExpires < 0 ) {
+ this.cacheValidity = NOPValidity.SHARED_INSTANCE;
}
final boolean purge = this.parameters.getParameterAsBoolean("purge-cache", false);