class Cache<K,V> extends Object
| Modifier and Type | Field and Description |
|---|---|
private ConcurrentHashMap<K,V> |
active
The active cache.
|
private ConcurrentHashMap<K,V> |
background
The background cache.
|
private long |
nextCacheService
The next time the caches should be switched.
|
private int |
serviceIntervalMS
The time between cache services.
|
| Constructor and Description |
|---|
Cache(int serviceInterval)
Constructs a new instance of the cache.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
service()
Service the cache by switching the lists if the next service time has
passed.
|
(package private) void |
setActive(K key,
V result) |
(package private) void |
setBackground(K key,
V result) |
(package private) V |
tryGetValue(K key)
Attempts to get the value with the given, or null if no key is found.
|
private long nextCacheService
private int serviceIntervalMS
private ConcurrentHashMap<K,V> active
private ConcurrentHashMap<K,V> background
public Cache(int serviceInterval)
serviceInterval - number of seconds between switching the cache.