Class SimpleWindowPartitionCache<K,V>
java.lang.Object
org.apache.storm.windowing.persistence.SimpleWindowPartitionCache<K,V>
- All Implemented Interfaces:
WindowPartitionCache<K,
V>
A simple implementation that evicts the largest un-pinned entry from the cache. This works well for caching window partitions since the
access pattern is mostly sequential scans.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Nested classes/interfaces inherited from interface org.apache.storm.windowing.persistence.WindowPartitionCache
WindowPartitionCache.Builder<K,
V>, WindowPartitionCache.CacheLoader<K, V>, WindowPartitionCache.RemovalCause, WindowPartitionCache.RemovalListener<K, V> -
Method Summary
Modifier and TypeMethodDescriptionasMap()
Return aConcurrentMap
view of the current entries in the cache.Get value from the cache or load the value.void
invalidate
(K key) Invalidate an entry from the cache.static <K,
V> SimpleWindowPartitionCache.SimpleWindowPartitionCacheBuilder<K, V> Get value from the cache or load the value pinning it so that the entry will never get evicted.boolean
Unpin an entry from the cache so that it can be a candidate for eviction.
-
Method Details
-
newBuilder
-
get
Description copied from interface:WindowPartitionCache
Get value from the cache or load the value.- Specified by:
get
in interfaceWindowPartitionCache<K,
V> - Parameters:
key
- the key- Returns:
- the value
-
pinAndGet
Description copied from interface:WindowPartitionCache
Get value from the cache or load the value pinning it so that the entry will never get evicted.- Specified by:
pinAndGet
in interfaceWindowPartitionCache<K,
V> - Parameters:
key
- the key- Returns:
- the value
-
unpin
Description copied from interface:WindowPartitionCache
Unpin an entry from the cache so that it can be a candidate for eviction.- Specified by:
unpin
in interfaceWindowPartitionCache<K,
V> - Parameters:
key
- the key- Returns:
- true if the entry was unpinned, false otherwise
-
asMap
Description copied from interface:WindowPartitionCache
Return aConcurrentMap
view of the current entries in the cache.- Specified by:
asMap
in interfaceWindowPartitionCache<K,
V> - Returns:
- the map of key-values currently cached.
-
invalidate
Description copied from interface:WindowPartitionCache
Invalidate an entry from the cache.- Specified by:
invalidate
in interfaceWindowPartitionCache<K,
V> - Parameters:
key
- the key
-