Package org.apache.storm.windowing.persistence

# 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 class`
  `SimpleWindowPartitionCache.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

  Modifier and Type
  Method
  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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### newBuilder

    public static <K, V> SimpleWindowPartitionCache.SimpleWindowPartitionCacheBuilder<K,V> newBuilder()

  - ### get

    public V get(K key)
    Description copied from interface: `WindowPartitionCache`
    Get value from the cache or load the value.
    Specified by:
      `get` in interface `WindowPartitionCache<K,V>`
    Parameters:
      `key` - the key
    Returns:
      the value

  - ### pinAndGet

    public V pinAndGet(K key)
    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 interface `WindowPartitionCache<K,V>`
    Parameters:
      `key` - the key
    Returns:
      the value

  - ### unpin

    public boolean unpin(K key)
    Description copied from interface: `WindowPartitionCache`
    Unpin an entry from the cache so that it can be a candidate for eviction.
    Specified by:
      `unpin` in interface `WindowPartitionCache<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: `WindowPartitionCache`
    Return a `ConcurrentMap` view of the current entries in the cache.
    Specified by:
      `asMap` in interface `WindowPartitionCache<K,V>`
    Returns:
      the map of key-values currently cached.

  - ### invalidate

    public void invalidate(K key)
    Description copied from interface: `WindowPartitionCache`
    Invalidate an entry from the cache.
    Specified by:
      `invalidate` in interface `WindowPartitionCache<K,V>`
    Parameters:
      `key` - the key