|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfiftyone.mobile.detection.Cache<K,V>
class Cache<K,V>
Used to speed the retrieval of detection results over duplicate requests.
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
Cache(int serviceInterval)
Constructs a new instance of the cache. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private long nextCacheService
private int serviceIntervalMS
private ConcurrentHashMap<K,V> active
private ConcurrentHashMap<K,V> background
| Constructor Detail |
|---|
public Cache(int serviceInterval)
serviceInterval - number of seconds between switching the cache.| Method Detail |
|---|
private void service()
V tryGetValue(K key)
void setActive(K key,
V result)
void setBackground(K key,
V result)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||