Package org.csstudio.java.thread
Class TimedCache<KEYTYPE,VALUETYPE>
java.lang.Object
org.csstudio.java.thread.TimedCache<KEYTYPE,VALUETYPE>
Thread-safe Cache for anything that times out after some time.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Use if need to get rid of all expired cache entriesGet entry from cacheGet value of entry from cacheAdd item to cache
-
Constructor Details
-
TimedCache
public TimedCache(long timeout_secs) Initialize cache- Parameters:
timeout_secs
- How long items are considered 'valid' in seconds
-
-
Method Details
-
getCacheStats
- Returns:
- Cache statistics
-
getEntry
Get entry from cache- Parameters:
key
-- Returns:
- Cached entry or
null
when not found or timed out
-
getValue
Get value of entry from cache- Parameters:
key
-- Returns:
- Cached value or
null
when not found or timed out
-
remember
Add item to cache- Parameters:
key
-value
-- Returns:
- Cache entry
-
cleanup
public void cleanup()Use if need to get rid of all expired cache entries
-