Class SimpleWindowPartitionCache<K,V>
- java.lang.Object
-
- org.apache.storm.windowing.persistence.SimpleWindowPartitionCache<K,V>
-
- All Implemented Interfaces:
WindowPartitionCache<K,V>
public class SimpleWindowPartitionCache<K,V> extends Object implements 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
Nested Classes Modifier and Type Class Description static classSimpleWindowPartitionCache.SimpleWindowPartitionCacheBuilder<K,V>-
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConcurrentMap<K,V>asMap()Return aConcurrentMapview of the current entries in the cache.Vget(K key)Get value from the cache or load the value.voidinvalidate(K key)Invalidate an entry from the cache.static <K,V>
SimpleWindowPartitionCache.SimpleWindowPartitionCacheBuilder<K,V>newBuilder()VpinAndGet(K key)Get value from the cache or load the value pinning it so that the entry will never get evicted.booleanunpin(K key)Unpin an entry from the cache so that it can be a candidate for eviction.
-
-
-
Method Detail
-
newBuilder
public static <K,V> SimpleWindowPartitionCache.SimpleWindowPartitionCacheBuilder<K,V> newBuilder()
-
get
public V get(K key)
Description copied from interface:WindowPartitionCacheGet value from the cache or load the value.- Specified by:
getin interfaceWindowPartitionCache<K,V>- Parameters:
key- the key- Returns:
- the value
-
pinAndGet
public V pinAndGet(K key)
Description copied from interface:WindowPartitionCacheGet value from the cache or load the value pinning it so that the entry will never get evicted.- Specified by:
pinAndGetin interfaceWindowPartitionCache<K,V>- Parameters:
key- the key- Returns:
- the value
-
unpin
public boolean unpin(K key)
Description copied from interface:WindowPartitionCacheUnpin an entry from the cache so that it can be a candidate for eviction.- Specified by:
unpinin interfaceWindowPartitionCache<K,V>- Parameters:
key- the key- Returns:
- true if the entry was unpinned, false otherwise
-
asMap
public ConcurrentMap<K,V> asMap()
Description copied from interface:WindowPartitionCacheReturn aConcurrentMapview of the current entries in the cache.- Specified by:
asMapin interfaceWindowPartitionCache<K,V>- Returns:
- the map of key-values currently cached.
-
invalidate
public void invalidate(K key)
Description copied from interface:WindowPartitionCacheInvalidate an entry from the cache.- Specified by:
invalidatein interfaceWindowPartitionCache<K,V>- Parameters:
key- the key
-
-