]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/cache/ITimedCache.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / cache / ITimedCache.java
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.utils.datastructures.cache;\r
13 \r
14 import java.util.concurrent.TimeUnit;\r
15 \r
16 /**\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
21  * \r
22  * @author Tuukka Lehtonen\r
23  * \r
24  * @see SoftTimedCache\r
25  * @param <K> key type\r
26  * @param <V> value type\r
27  */\r
28 public interface ITimedCache<K, V> {\r
29 \r
30     /**\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
34      * \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
38      *        specified value\r
39      * @param unit the unit of <code>holdTime</code>\r
40      */\r
41     void put(final K k, V v, long holdTime, TimeUnit unit);\r
42 \r
43     /**\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
47      * returned.\r
48      * \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
51      *         specified key\r
52      */\r
53     V release(K k);\r
54 \r
55 }\r