Module com.aoapps.dao.base
Package com.aoapps.dao.base
Class TableCacheTable<K extends Comparable<? super K>,R extends Row<K,?>>
java.lang.Object
com.aoapps.dao.base.AbstractTable<K,R>
com.aoapps.dao.base.TableCacheTable<K,R>
- All Implemented Interfaces:
Table<K,
,R> Iterable<R>
,Collection<R>
public abstract class TableCacheTable<K extends Comparable<? super K>,R extends Row<K,?>>
extends AbstractTable<K,R>
Caches results by querying the entire table upon first use. The cache is
per-request and per-user.
- All rows are loaded and stored unsorted
- allRowsLoaded is called, given unsorted rows
- Map is built upon first call to get(K)
- Rows are sorted upon first call to getRows
-
Field Summary
Fields inherited from class com.aoapps.dao.base.AbstractTable
map, sortedMap
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
allRowsLoaded
(Set<? extends R> rows) Called when all rows have been loaded at once.void
Clears all caches for the current thread.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
-
TableCacheTable
-
-
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.This default implementation does nothing.
- Throws:
SQLException
-
getRows
- Throws:
SQLException
-
get
- Throws:
NoRowException
SQLException
-
getRowsNoCache
- Throws:
SQLException
-