morrijr 01/11/16 05:54:53 Added: src/org/apache/cocoon/caching DeltaTimeCacheValidity.java Log: Keeps the result of an XSP page in cache for a specified amount of time - Michael Homeijer (mailto:[EMAIL PROTECTED]) Revision Changes Path 1.1 xml-cocoon2/src/org/apache/cocoon/caching/DeltaTimeCacheValidity.java Index: DeltaTimeCacheValidity.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.caching; import java.util.Date; import java.lang.Math; /** * A validation object that remains valid for a specified amount of time (minutes). * * @author Michael Homeijer */ public final class DeltaTimeCacheValidity implements CacheValidity { private long cachedDateTime; // Holds the store-time in miliseconds private long timeInCache; // maximum time allowed in cache in minutes public DeltaTimeCacheValidity(long timeInCache) { this.cachedDateTime = new Date().getTime(); this.timeInCache = timeInCache * 60000; } public boolean isValid(CacheValidity validity) { if (validity instanceof DeltaTimeCacheValidity) { return Math.abs((((DeltaTimeCacheValidity)validity).getCachedDateTime() - this.cachedDateTime)) < this.timeInCache; } return false; } public long getCachedDateTime() { return this.cachedDateTime; } public String toString() { return "DeltaTimeCacheValidity: " + this.cachedDateTime + "(+" + this.timeInCache + "min)"; } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]