]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/cache/ITimedCache.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / cache / ITimedCache.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.datastructures.cache;
13
14 import java.util.concurrent.TimeUnit;
15
16 /**
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.
21  * 
22  * @author Tuukka Lehtonen
23  * 
24  * @see SoftTimedCache
25  * @param <K> key type
26  * @param <V> value type
27  */
28 public interface ITimedCache<K, V> {
29
30     /**
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.
34      * 
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
38      *        specified value
39      * @param unit the unit of <code>holdTime</code>
40      */
41     void put(final K k, V v, long holdTime, TimeUnit unit);
42
43     /**
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
47      * returned.
48      * 
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
51      *         specified key
52      */
53     V release(K k);
54
55 }