-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathMainApplication.java
More file actions
29 lines (22 loc) · 882 Bytes
/
MainApplication.java
File metadata and controls
29 lines (22 loc) · 882 Bytes
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
package com.lld.inmemorycache;
import com.lld.inmemorycache.service.EvictionPolicy;
import com.lld.inmemorycache.service.impl.Cache;
import com.lld.inmemorycache.service.impl.InMemoryStorage;
import com.lld.inmemorycache.service.impl.policy.LRUEvictionPolicy;
import java.util.Objects;
public class MainApplication {
public static void main(String[] args)
{
InMemoryStorage inMemoryStorage = new InMemoryStorage();
EvictionPolicy lruEvictionPolicy = new LRUEvictionPolicy();
Cache cache = new Cache(inMemoryStorage, lruEvictionPolicy, 2);
// Test 1
cache.put("c", "1");
cache.put("a", "1");
cache.put("a", "2");
assert Objects.equals(cache.get("a"), "2");
cache.put("b", "3");
cache.put("b", "4");
assert Objects.equals(cache.get("b"), "4");
}
}