Class JDBCStatementCache.BoundedLinkedHashMap
java.lang.Object
java.util.AbstractMap<StatementKey, PreparedStatement>
java.util.HashMap<StatementKey, PreparedStatement>
java.util.LinkedHashMap<StatementKey, PreparedStatement>
org.apache.derby.client.am.stmtcache.JDBCStatementCache.BoundedLinkedHashMap
- All Implemented Interfaces:
Serializable, Cloneable, Map<StatementKey, PreparedStatement>, SequencedMap<StatementKey, PreparedStatement>
- Enclosing class:
JDBCStatementCache
private static class JDBCStatementCache.BoundedLinkedHashMap
extends LinkedHashMap<StatementKey, PreparedStatement>
A
LinkedHashMap with an upper bound on the number of entries.
If the maximum size is exceeded, the oldest entry is automatically removed after the new entry has been inserted.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBoundedLinkedHashMap(int maxCapacity) Creates a boundedLinkedHashMapwith the specified maximum size. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanTells if an entry should be removed from the map.Methods inherited from class LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class AbstractMap
equals, hashCode, toStringMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from interface SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Field Details
-
maxSize
private final int maxSizeMaximum number of entries.
-
-
Constructor Details
-
BoundedLinkedHashMap
public BoundedLinkedHashMap(int maxCapacity) Creates a boundedLinkedHashMapwith the specified maximum size.Iteration is by insertion-order.
- Parameters:
maxCapacity- maximum size of the map
-
-
Method Details
-
removeEldestEntry
Tells if an entry should be removed from the map.If the cache has exceeded its maximum size, the oldest element will be marked for removal. The oldest element will be removed after the new element has been inserted.
- Overrides:
removeEldestEntryin classLinkedHashMap<StatementKey, PreparedStatement>- Parameters:
eldest- the element picked out for removal- Returns:
trueif the element is to be removed,falseif not.
-