1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.utils.datastructures.cache;
\r
14 import java.util.concurrent.TimeUnit;
\r
17 * A timed (Key, Value) cache which disposes the cached entry after the
\r
18 * specified amount of time if it is not released from the cache during that
\r
19 * time. The hold time is given to the {@link #put(Object, Object, long)}
\r
20 * method, separately for each value.
\r
22 * @author Tuukka Lehtonen
\r
24 * @see SoftTimedCache
\r
25 * @param <K> key type
\r
26 * @param <V> value type
\r
28 public interface ITimedCache<K, V> {
\r
31 * Put the value v into this cache with key k to be kept for holdTimeMs
\r
32 * milliseconds. After this times has elapsed, the (k,v) pair will be
\r
33 * disposed of and it will no longer be retrievable with key k.
\r
35 * @param k key with which the specified value is to be associated
\r
36 * @param v value to be associated with the specified key
\r
37 * @param holdTime the maximum amount of time units to hold on to the
\r
39 * @param unit the unit of <code>holdTime</code>
\r
41 void put(final K k, V v, long holdTime, TimeUnit unit);
\r
44 * Releases the value associated to the specified key k from this cache. If
\r
45 * the hold time for this particular (key, value) pair has ran out, the
\r
46 * value will no longer exist in the cache and <code>null</code> will be
\r
49 * @param k key of the value to release from the cache.
\r
50 * @return <code>null</code> if there is no value associated to the
\r