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.
- Alphabetic
- By Inheritance
- LRUMap
- LinkedListElem
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new LRUMap(size: Int)
- new LRUMap(initMaxSize: Int, loadFactor: Box[Float], expiredFunc: (K, V) => Unit*)
- loadFactor
If non-
Empty, specifies the load factor for the backingjava.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
expiredis invoked.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def -(key: K): Unit
Remove the given
keyand its associated value from the map. - final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(key: K): V
Unsafe version of
get. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- 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
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def contains(key: K): Boolean
Check if the given
keyexists in the map.Check if the given
keyexists in the map. A key may not be in the map either if it was never added or if it has been expired. - def elements: Iterator[(K, V)]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def get(key: K): Box[V]
Fetches the given key, returning
Emptyif the key does not exist in the map.Fetches the given key, returning
Emptyif 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.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def keys: List[K]
- def maxSize: Int
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def remove(key: K): Unit
Alias for
-. - def size: Int
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def update(key: K, value: V): Unit
Set the
valuefor the givenkeyin the map.Set the
valuefor the givenkeyin the map.Marks the given
valueas the most recently used, and, if thiskeyis new in the map and the map has grown beyond the specifiexmaxSize, evicts the least-recently-used entries. - def updateMaxSize(newMaxSize: Int): Unit
Updates the
LRUMap's current max size tonewMaxSize, evicting the oldest entries if the size has shrunk. - final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()