Class JDBCStatementCache.BoundedLinkedHashMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<StatementKey,java.sql.PreparedStatement>
-
- org.apache.derby.client.am.stmtcache.JDBCStatementCache.BoundedLinkedHashMap
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<StatementKey,java.sql.PreparedStatement>
- Enclosing class:
- JDBCStatementCache
private static class JDBCStatementCache.BoundedLinkedHashMap extends java.util.LinkedHashMap<StatementKey,java.sql.PreparedStatement>
ALinkedHashMap
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.
-
-
Field Summary
Fields Modifier and Type Field Description private int
maxSize
Maximum number of entries.
-
Constructor Summary
Constructors Constructor Description BoundedLinkedHashMap(int maxCapacity)
Creates a boundedLinkedHashMap
with the specified maximum size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
removeEldestEntry(java.util.Map.Entry<StatementKey,java.sql.PreparedStatement> eldest)
Tells if an entry should be removed from the map.-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Method Detail
-
removeEldestEntry
protected boolean removeEldestEntry(java.util.Map.Entry<StatementKey,java.sql.PreparedStatement> eldest)
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:
removeEldestEntry
in classjava.util.LinkedHashMap<StatementKey,java.sql.PreparedStatement>
- Parameters:
eldest
- the element picked out for removal- Returns:
true
if the element is to be removed,false
if not.
-
-