@Deprecated @NotThreadSafe public class

LRUMap

extends LinkedHashMap<K, V>
implements Map<K, V>
java.lang.Object
   ↳ java.util.AbstractMap<K, V>
     ↳ java.util.HashMap<K, V>
       ↳ java.util.LinkedHashMap<K, V>
         ↳ com.atlassian.jira.util.collect.LRUMap<K, V>

This class is deprecated.
Since v6.2 Use com.atlassian.cache.CacheFactory instead and build a proper cache.

Class Overview

A subclass of LinkedHashMap that is access ordered AND constrained in size.

It is very important that any multi-threaded access to this class be externally synchronised as even non mutative operations such as get(Object) will cause internal modifications to the map order.

See Also

Summary

Public Methods
static <K, V> Map<K, V> newLRUMap(int capacity)
Get a map that is access ordered and has the specified capacity.
static <K, V> Map<K, V> synchronizedLRUMap(int capacity)
Get a map that is access ordered and has the specified capacity that is thread-safe.
Protected Methods
final boolean removeEldestEntry(Entry<K, V> eldest)
[Expand]
Inherited Methods
From class java.util.LinkedHashMap
From class java.util.HashMap
From class java.util.AbstractMap
From class java.lang.Object
From interface java.util.Map

Public Methods

public static Map<K, V> newLRUMap (int capacity)

Get a map that is access ordered and has the specified capacity.

Parameters
capacity the maximum capacity
Returns
  • an instance of LRUMap

public static Map<K, V> synchronizedLRUMap (int capacity)

Get a map that is access ordered and has the specified capacity that is thread-safe.

Parameters
capacity the maximum capacity
Returns
  • an instance of LRUMap wrapped in a synchronized map.

Protected Methods

protected final boolean removeEldestEntry (Entry<K, V> eldest)