-
Notifications
You must be signed in to change notification settings - Fork 30
/
Cache.java
53 lines (45 loc) · 1.02 KB
/
Cache.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package hotchemi.com.github;
/**
* A memory cache interface.
*
* @author Shintaro Katafuchi
*/
public interface Cache<K, V> {
/**
* Gets an value for the specified {@code key} or return {@code null}.
*
* @param key key
* @return the value or {@code null}.
*/
V get(K key);
/**
* Puts an value in the cache for the specified {@code key}.
*
* @param key key
* @param value image
* @return the previous value.
*/
V put(K key, V value);
/**
* Removes the entry for {@code key} if it exists or return {@code null}.
*
* @return the previous value or @{code null}.
*/
V remove(K key);
/**
* Clears all the entries in the cache.
*/
void clear();
/**
* Returns the max memory size of the cache.
*
* @return max memory size.
*/
int getMaxMemorySize();
/**
* Returns the current memory size of the cache.
*
* @return current memory size.
*/
int getMemorySize();
}