Class AbstractMapQueryResultsCache
java.lang.Object
org.datanucleus.store.query.cache.AbstractMapQueryResultsCache
- All Implemented Interfaces:
Serializable, QueryResultsCache
- Direct Known Subclasses:
SoftQueryResultsCache, StrongQueryResultsCache, WeakQueryResultsCache
Abstract representation of a query results cache for the query based on a map.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionCache of unpinned objects.private static final PatternKeys to pin, if entering into the cache.private intprivate final NucleusContextCache of pinned objects.private static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Method to close the cache when no longer needed.booleanAccessor for whether the specified query is in the cachevoidMethod to evict all queries that use the provided class as candidate.voidEvict the query from the results cache.voidEvict the query with the specified params from the results cache.voidevictAll()Method to clear the cache.Accessor for the results from the cache.booleanisEmpty()Accessor for whether the cache is empty.voidMethod to pin the specified query in the cache, preventing garbage collection.voidMethod to pin the specified query in the cache, preventing garbage collection.Method to put an object in the cache.intsize()Accessor for the total number of results in the query cache.voidMethod to unpin the specified query from the cache, allowing garbage collection.voidMethod to unpin the specified query from the cache, allowing garbage collection.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
EVICT_PATTERN
-
keysToPin
-
pinnedCache
-
cache
-
maxSize
private int maxSize -
nucCtx
-
-
Constructor Details
-
AbstractMapQueryResultsCache
-
-
Method Details
-
close
public void close()Description copied from interface:QueryResultsCacheMethod to close the cache when no longer needed. Provides a hook to release resources etc.- Specified by:
closein interfaceQueryResultsCache
-
contains
Description copied from interface:QueryResultsCacheAccessor for whether the specified query is in the cache- Specified by:
containsin interfaceQueryResultsCache- Parameters:
queryKey- The query key- Returns:
- Whether it is in the cache
-
evict
Description copied from interface:QueryResultsCacheMethod to evict all queries that use the provided class as candidate. This is usually called when an instance of the candidate has been changed in the datastore.- Specified by:
evictin interfaceQueryResultsCache- Parameters:
candidate- The candidate
-
evictAll
public void evictAll()Description copied from interface:QueryResultsCacheMethod to clear the cache.- Specified by:
evictAllin interfaceQueryResultsCache
-
evict
Description copied from interface:QueryResultsCacheEvict the query from the results cache.- Specified by:
evictin interfaceQueryResultsCache- Parameters:
query- The query to evict (evicts all use of this query, with any params)
-
evict
Description copied from interface:QueryResultsCacheEvict the query with the specified params from the results cache.- Specified by:
evictin interfaceQueryResultsCache- Parameters:
query- The query to evictparams- The parameters
-
pin
Description copied from interface:QueryResultsCacheMethod to pin the specified query in the cache, preventing garbage collection.- Specified by:
pinin interfaceQueryResultsCache- Parameters:
query- The queryparams- Its params
-
pin
Description copied from interface:QueryResultsCacheMethod to pin the specified query in the cache, preventing garbage collection.- Specified by:
pinin interfaceQueryResultsCache- Parameters:
query- The query
-
unpin
Description copied from interface:QueryResultsCacheMethod to unpin the specified query from the cache, allowing garbage collection.- Specified by:
unpinin interfaceQueryResultsCache- Parameters:
query- The queryparams- Its params
-
unpin
Description copied from interface:QueryResultsCacheMethod to unpin the specified query from the cache, allowing garbage collection.- Specified by:
unpinin interfaceQueryResultsCache- Parameters:
query- The query
-
get
Description copied from interface:QueryResultsCacheAccessor for the results from the cache.- Specified by:
getin interfaceQueryResultsCache- Parameters:
queryKey- The query key- Returns:
- The cached query result ids
-
isEmpty
public boolean isEmpty()Description copied from interface:QueryResultsCacheAccessor for whether the cache is empty.- Specified by:
isEmptyin interfaceQueryResultsCache- Returns:
- Whether it is empty.
-
put
Description copied from interface:QueryResultsCacheMethod to put an object in the cache.- Specified by:
putin interfaceQueryResultsCache- Parameters:
queryKey- The query keyresults- The results for this query- Returns:
- The result ids previously associated with this query (if any)
-
size
public int size()Description copied from interface:QueryResultsCacheAccessor for the total number of results in the query cache.- Specified by:
sizein interfaceQueryResultsCache- Returns:
- Number of queries
-