cascading.util.cache

## Class LRUHashMapCache<Key,Value>

- java.lang.Object
- - cascading.util.cache.LRUHashMapCache<Key,Value>

- All Implemented Interfaces:
    CascadingCache<Key,Value>, java.util.Map<Key,Value>

      public class LRUHashMapCache<Key,Value>
      extends java.lang.Object
      implements CascadingCache<Key,Value>

  Implementation of the `CascadingCache` interface backed by a `LinkedHashMap` configured to evict the least recently used key.

  That is, if duplicate keys are clustered near each other in the incoming tuple stream, this cache will provide the most benefit as keys that begin to occur less frequently or not at all will be evicted as the key capacity is reached.

  If the keys are very random, if not uniformly distributed in the stream, consider using the `DirectMappedCache` to reduce the amount of hash and equality comparisons.

  This implementation is used by default by `Unique` and `AggregateBy` and their subclasses.
  See Also:
    `Unique`, `AggregateBy`, `LRUHashMapCacheFactory`, `DirectMappedCacheFactory`, `DirectMappedCache`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `java.util.Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LRUHashMapCache()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()`
    `boolean` | `containsKey(java.lang.Object key)`
    `boolean` | `containsValue(java.lang.Object value)`
    `java.util.Set<java.util.Map.Entry<Key,Value>>` | `entrySet()`
    `Value` | `get(java.lang.Object key)`
    `int` | `getCapacity()` Returns the capacity of this cache.
    `void` | `initialize()` Method to initialize the Cache.
    `boolean` | `isEmpty()`
    `java.util.Set<Key>` | `keySet()`
    `Value` | `put(Key key, Value value)`
    `void` | `putAll(java.util.Map<? extends Key,? extends Value> m)`
    `Value` | `remove(java.lang.Object key)`
    `void` | `setCacheEvictionCallback(CacheEvictionCallback cacheEvictionCallback)` Sets the `CacheEvictionCallback` of this Cache.
    `void` | `setCapacity(int capacity)` Sets the capacity of the Cache.
    `int` | `size()`
    `java.util.Collection<Value>` | `values()`

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

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

    - ### Methods inherited from interface java.util.Map

      `equals, hashCode`

- - ### Constructor Detail

    - #### LRUHashMapCache

          public LRUHashMapCache()

  - ### Method Detail

    - #### getCapacity

          public int getCapacity()

      Description copied from interface: `CascadingCache`
      Returns the capacity of this cache.
      Specified by:
        `getCapacity` in interface `CascadingCache<Key,Value>`

    - #### setCacheEvictionCallback

          public void setCacheEvictionCallback(CacheEvictionCallback cacheEvictionCallback)

      Description copied from interface: `CascadingCache`
      Sets the `CacheEvictionCallback` of this Cache.
      Specified by:
        `setCacheEvictionCallback` in interface `CascadingCache<Key,Value>`

    - #### setCapacity

          public void setCapacity(int capacity)

      Description copied from interface: `CascadingCache`
      Sets the capacity of the Cache.
      Specified by:
        `setCapacity` in interface `CascadingCache<Key,Value>`

    - #### initialize

          public void initialize()

      Description copied from interface: `CascadingCache`
      Method to initialize the Cache. Any setup should be done in here.
      Specified by:
        `initialize` in interface `CascadingCache<Key,Value>`

    - #### size

          public int size()

      Specified by:
        `size` in interface `java.util.Map<Key,Value>`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `java.util.Map<Key,Value>`

    - #### containsKey

          public boolean containsKey(java.lang.Object key)

      Specified by:
        `containsKey` in interface `java.util.Map<Key,Value>`

    - #### containsValue

          public boolean containsValue(java.lang.Object value)

      Specified by:
        `containsValue` in interface `java.util.Map<Key,Value>`

    - #### get

          public Value get(java.lang.Object key)

      Specified by:
        `get` in interface `java.util.Map<Key,Value>`

    - #### put

          public Value put(Key key,
                  Value value)

      Specified by:
        `put` in interface `java.util.Map<Key,Value>`

    - #### remove

          public Value remove(java.lang.Object key)

      Specified by:
        `remove` in interface `java.util.Map<Key,Value>`

    - #### putAll

          public void putAll(java.util.Map<? extends Key,? extends Value> m)

      Specified by:
        `putAll` in interface `java.util.Map<Key,Value>`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `java.util.Map<Key,Value>`

    - #### keySet

          public java.util.Set<Key> keySet()

      Specified by:
        `keySet` in interface `java.util.Map<Key,Value>`

    - #### values

          public java.util.Collection<Value> values()

      Specified by:
        `values` in interface `java.util.Map<Key,Value>`

    - #### entrySet

          public java.util.Set<java.util.Map.Entry<Key,Value>> entrySet()

      Specified by:
        `entrySet` in interface `java.util.Map<Key,Value>`

Copyright © 2007-2015 Xplenty, Inc. All Rights Reserved.