001package org.cache2k; 002 003/* 004 * #%L 005 * cache2k API 006 * %% 007 * Copyright (C) 2000 - 2016 headissue GmbH, Munich 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import org.cache2k.expiry.ExpiryPolicy; 024 025/** 026 * Calculates the time when the object needs to be updated next. 027 * 028 * @author Jens Wilke; created: 2010-06-24 029 * @deprecated use {@link ExpiryPolicy} 030 */ 031public abstract interface RefreshController<T> { 032 033 /** 034 * Returns the time of next refresh (expiry time) in milliseconds since epoch. 035 * If 0 is returned, this means entry expires immediately, or is always 036 * fetched from the source. If {@link Long#MAX_VALUE} is returned it means 037 * there is no specific expiry time known or needed. In case a reasonable 038 * default can be assumed for the expiry, the cache will use the 039 * configured expiry time. 040 * 041 * <p>The cache may call the method a second (or more) times, if the 042 * expiry time needs a recalculation. The reason for this is to react on 043 * possible configuration changes properly. This may happen when an entry 044 * is read back from storage. 045 * 046 * @param _oldObject the value currently in the cache. null if it is not 047 * in the cache, is a null value (null is supported for values) 048 * or the previous fetch operation yielded in an exception. 049 * @param _timeOfLastRefresh time of the last cache refresh, by put or from the cache source. 050 * @param _newObject the value which will be put in the cache. 051 * @param _fetchTime this is the current time in millis. If a cache source was used to 052 * fetch the value, this is the time before the fetch was started. 053 * @return time of next refresh in millis. 0 if it should not be cached at all. 054 */ 055 public abstract long calculateNextRefreshTime( 056 T _oldObject, 057 T _newObject, 058 long _timeOfLastRefresh, 059 long _fetchTime); 060 061}