Module com.aoapps.dao.base
Package com.aoapps.dao.base
Class RowCacheTable<K extends Comparable<? super K>,R extends Row<K,?>>
java.lang.Object
com.aoapps.dao.base.AbstractTable<K,R>
com.aoapps.dao.base.RowCacheTable<K,R>
- All Implemented Interfaces:
Table<K,
,R> Iterable<R>
,Collection<R>
public abstract class RowCacheTable<K extends Comparable<? super K>,R extends Row<K,?>>
extends AbstractTable<K,R>
Caches results on a per-row basis.
-
Field Summary
Fields inherited from class com.aoapps.dao.base.AbstractTable
map, sortedMap
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToCache
(K canonicalKey, R row) Adds a single object to the cache.protected void
allRowsLoaded
(Set<? extends R> rows) Called when all rows have been loaded at once.void
Clears all caches for the current thread.protected abstract R
getNoCache
(K canonicalKey) getRows()
void
When the table is updated, all caches are cleared for the current thread.Methods inherited from class com.aoapps.dao.base.AbstractTable
getMap, getModel, getSortedMap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
Methods inherited from interface com.aoapps.dao.Table
add, addAll, canonicalize, clear, contains, containsAll, getIterator, getName, getOrderedRows, getRows, getSize, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
-
Field Details
-
unsortedRowsCache
-
-
Constructor Details
-
RowCacheTable
-
-
Method Details
-
clearCaches
public void clearCaches()Clears all caches for the current thread. -
tableUpdated
public void tableUpdated()When the table is updated, all caches are cleared for the current thread. -
getUnsortedRows
- Throws:
SQLException
-
allRowsLoaded
Called when all rows have been loaded at once. This allows for subclasses to populate any views or caches in a more efficient manner than row-by-row.This default implementation does nothing.
- Throws:
SQLException
-
getRows
- Throws:
SQLException
-
get
- Throws:
NoRowException
SQLException
-
addToCache
Adds a single object to the cache. -
getNoCache
- Throws:
NoRowException
SQLException
-
getRowsNoCache
- Throws:
SQLException
-