Skip to content

Package: Cache

Cache

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2020 Eurotech and/or its affiliates and others
3: *
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: * Eurotech - initial API and implementation
11: *******************************************************************************/
12: package org.eclipse.kapua.commons.cache;
13:
14: /**
15: * Kapua cache definition
16: *
17: * @param <K>
18: * keys type
19: * @param <V>
20: * values type
21: *
22: * @since 1.0
23: */
24: public interface Cache<K, V> {
25:
26: /**
27: * Return the metric namespace
28: *
29: * @return
30: */
31: public String getNamespace();
32:
33: /**
34: * Set the metric namespace
35: *
36: * @param namespace
37: */
38: public void setNamespace(String namespace);
39:
40: /**
41: * Return the cache value for the given key
42: *
43: * @param k
44: * @return
45: */
46: public V get(K k);
47:
48: /**
49: * Set the cache value for the given key
50: *
51: * @param k
52: * @param v
53: */
54: public void put(K k, V v);
55:
56: /**
57: * Remove the cache value for the given key.<BR>
58: * No exception will be thrown if the value is not present
59: *
60: * @param k
61: */
62: public void remove(K k);
63:
64: /**
65: * Clear the cache
66: */
67: public void invalidateAll();
68:
69: }