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
- All
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
expired
is 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
key
and 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[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
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. - def elements: Iterator[(K, V)]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): 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[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
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.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
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
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
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
value
for the givenkey
in the map.Set the
value
for the givenkey
in the map.Marks the given
value
as the most recently used, and, if thiskey
is 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( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )