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.
Modifier and Type | Class and Description |
---|---|
static class |
SimpleWindowPartitionCache.SimpleWindowPartitionCacheBuilder<K,V> |
WindowPartitionCache.Builder<K,V>, WindowPartitionCache.CacheLoader<K,V>, WindowPartitionCache.RemovalCause, WindowPartitionCache.RemovalListener<K,V>
Modifier and Type | Method and Description |
---|---|
ConcurrentMap<K,V> |
asMap()
Return a
ConcurrentMap view of the current entries in the cache. |
V |
get(K key)
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> |
newBuilder() |
V |
pinAndGet(K key)
Get value from the cache or load the value pinning it so that the entry will never get evicted.
|
boolean |
unpin(K key)
Unpin an entry from the cache so that it can be a candidate for eviction.
|
public static <K,V> SimpleWindowPartitionCache.SimpleWindowPartitionCacheBuilder<K,V> newBuilder()
public V get(K key)
WindowPartitionCache
Get value from the cache or load the value.
get
in interface WindowPartitionCache<K,V>
key
- the keypublic V pinAndGet(K key)
WindowPartitionCache
Get value from the cache or load the value pinning it so that the entry will never get evicted.
pinAndGet
in interface WindowPartitionCache<K,V>
key
- the keypublic boolean unpin(K key)
WindowPartitionCache
Unpin an entry from the cache so that it can be a candidate for eviction.
unpin
in interface WindowPartitionCache<K,V>
key
- the keypublic ConcurrentMap<K,V> asMap()
WindowPartitionCache
Return a ConcurrentMap
view of the current entries in the cache.
asMap
in interface WindowPartitionCache<K,V>
public void invalidate(K key)
WindowPartitionCache
Invalidate an entry from the cache.
invalidate
in interface WindowPartitionCache<K,V>
key
- the keyCopyright © 2022 The Apache Software Foundation. All rights reserved.