class LRUMap[K, V] extends LinkedListElem[K, V]

Implements an LRU Hashmap. Given a size, this map will evict the least recently used item(s) when new items are added.

Note that LRUMap is not thread-safe.

Linear Supertypes
LinkedListElem[K, V], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LRUMap
  2. LinkedListElem
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new LRUMap(size: Int)
  2. new LRUMap(initMaxSize: Int, loadFactor: Box[Float], expiredFunc: (K, V) ⇒ Unit*)

    loadFactor

    If non-Empty, specifies the load factor for the backing java.util.HashMap.

    expiredFunc

    When a key-value pair is removed, the last thing that happens is that these functions are invoked. Note that this happens after expired is invoked.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def -(key: K): Unit

    Remove the given key and its associated value from the map.

  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def apply(key: K): V

    Unsafe version of get.

    Unsafe version of get.

    Exceptions thrown

    NullPointerException If the key does not exist in the map. Use get instead to get a safe Box result that can be checked for existence, or use contains before calling this.

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def canExpire(k: K, v: V): Boolean

    Override this method to implement a test to see if a particular element can be expired from the cache.

    Override this method to implement a test to see if a particular element can be expired from the cache.

    Attributes
    protected
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def contains(key: K): Boolean

    Check if the given key exists in the map.

    Check if the given key exists in the map. A key may not be in the map either if it was never added or if it has been expired.

  10. def elements: Iterator[(K, V)]
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def expired(key: K, value: V): Unit

    Called when a key/value pair is removed, before the expiredFunc.

    Called when a key/value pair is removed, before the expiredFunc.

    Does nothing by default, override for custom functionality.

    Attributes
    protected
  14. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def get(key: K): Box[V]

    Fetches the given key, returning Empty if the key does not exist in the map.

    Fetches the given key, returning Empty if the key does not exist in the map. A key may not be in the map either if it was never added or if it has been expired.

    Accessing a key this way will mark its value as most-recently-used.

  16. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def keys: List[K]
  20. def maxSize: Int
  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  24. def remove(key: K): Unit

    Alias for -.

  25. def size: Int
  26. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  27. def toString(): String
    Definition Classes
    AnyRef → Any
  28. def update(key: K, value: V): Unit

    Set the value for the given key in the map.

    Set the value for the given key in the map.

    Marks the given value as the most recently used, and, if this key is new in the map and the map has grown beyond the specifiex maxSize, evicts the least-recently-used entries.

  29. def updateMaxSize(newMaxSize: Int): Unit

    Updates the LRUMap's current max size to newMaxSize, evicting the oldest entries if the size has shrunk.

  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from LinkedListElem[K, V]

Inherited from AnyRef

Inherited from Any

Ungrouped