Class TimedCache<KEYTYPE,VALUETYPE>

java.lang.Object
org.csstudio.java.thread.TimedCache<KEYTYPE,VALUETYPE>

public class TimedCache<KEYTYPE,VALUETYPE> extends Object
Thread-safe Cache for anything that times out after some time.
  • Constructor Details

    • TimedCache

      public TimedCache(long timeout_secs)
      Initialize cache
      Parameters:
      timeout_secs - How long items are considered 'valid' in seconds
  • Method Details

    • getCacheStats

      public CacheStats getCacheStats()
      Returns:
      Cache statistics
    • getEntry

      public TimedCacheEntry<VALUETYPE> getEntry(KEYTYPE key)
      Get entry from cache
      Parameters:
      key -
      Returns:
      Cached entry or null when not found or timed out
    • getValue

      public VALUETYPE getValue(KEYTYPE key)
      Get value of entry from cache
      Parameters:
      key -
      Returns:
      Cached value or null when not found or timed out
    • remember

      public TimedCacheEntry<VALUETYPE> remember(KEYTYPE key, VALUETYPE value)
      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