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