Package com.booksaw.betterTeams.util
Class Cache<K,V>
java.lang.Object
com.booksaw.betterTeams.util.Cache<K,V>
- Type Parameters:
K- The type of keys maintained by this cacheV- The type of values maintained by this cache
A simple cache implementation with expiration and size-based eviction.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder for creating Cache instances. -
Method Summary
Modifier and TypeMethodDescriptionGets a value from the cache, loading it if necessary.voidinvalidate(K key) Removes an entry from the cache.voidRemoves all entries from the cache.intsize()Returns the approximate number of entries in this cache.
-
Method Details
-
get
Gets a value from the cache, loading it if necessary.- Parameters:
key- the key to look up- Returns:
- the value associated with the key
-
size
public int size()Returns the approximate number of entries in this cache. -
invalidateAll
public void invalidateAll()Removes all entries from the cache. -
invalidate
Removes an entry from the cache.- Parameters:
key- the key to remove
-