Class

net.liftweb.common

LRUMap

Related Doc: package common

Permalink

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)

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

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def -(key: K): Unit

    Permalink

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

  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. def apply(key: K): V

    Permalink

    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

    Permalink
    Definition Classes
    Any
  7. def canExpire(k: K, v: V): Boolean

    Permalink

    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

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

    Permalink

    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)]

    Permalink
  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  13. def expired(key: K, value: V): Unit

    Permalink

    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

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

    Permalink

    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[_]

    Permalink
    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. def keys: List[K]

    Permalink
  20. def maxSize: Int

    Permalink
  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. def remove(key: K): Unit

    Permalink

    Alias for -.

  25. def size: Int

    Permalink
  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  28. def update(key: K, value: V): Unit

    Permalink

    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

    Permalink

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

  30. final def wait(): Unit

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from LinkedListElem[K, V]

Inherited from AnyRef

Inherited from Any

Ungrouped