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 Pattern
Keys to pin, if entering into the cache.private int
private final NucleusContext
Cache of pinned objects.private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Method to close the cache when no longer needed.boolean
Accessor for whether the specified query is in the cachevoid
Method to evict all queries that use the provided class as candidate.void
Evict the query from the results cache.void
Evict the query with the specified params from the results cache.void
evictAll()
Method to clear the cache.Accessor for the results from the cache.boolean
isEmpty()
Accessor for whether the cache is empty.void
Method to pin the specified query in the cache, preventing garbage collection.void
Method to pin the specified query in the cache, preventing garbage collection.Method to put an object in the cache.int
size()
Accessor for the total number of results in the query cache.void
Method to unpin the specified query from the cache, allowing garbage collection.void
Method to unpin the specified query from the cache, allowing garbage collection.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
EVICT_PATTERN
-
keysToPin
Keys to pin, if entering into the cache. -
pinnedCache
Cache of pinned objects. -
cache
Cache of unpinned objects. -
maxSize
private int maxSize -
nucCtx
-
-
Constructor Details
-
AbstractMapQueryResultsCache
-
-
Method Details
-
close
public void close()Description copied from interface:QueryResultsCache
Method to close the cache when no longer needed. Provides a hook to release resources etc.- Specified by:
close
in interfaceQueryResultsCache
-
contains
Description copied from interface:QueryResultsCache
Accessor for whether the specified query is in the cache- Specified by:
contains
in interfaceQueryResultsCache
- Parameters:
queryKey
- The query key- Returns:
- Whether it is in the cache
-
evict
Description copied from interface:QueryResultsCache
Method 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:
evict
in interfaceQueryResultsCache
- Parameters:
candidate
- The candidate
-
evictAll
public void evictAll()Description copied from interface:QueryResultsCache
Method to clear the cache.- Specified by:
evictAll
in interfaceQueryResultsCache
-
evict
Description copied from interface:QueryResultsCache
Evict the query from the results cache.- Specified by:
evict
in interfaceQueryResultsCache
- Parameters:
query
- The query to evict (evicts all use of this query, with any params)
-
evict
Description copied from interface:QueryResultsCache
Evict the query with the specified params from the results cache.- Specified by:
evict
in interfaceQueryResultsCache
- Parameters:
query
- The query to evictparams
- The parameters
-
pin
Description copied from interface:QueryResultsCache
Method to pin the specified query in the cache, preventing garbage collection.- Specified by:
pin
in interfaceQueryResultsCache
- Parameters:
query
- The queryparams
- Its params
-
pin
Description copied from interface:QueryResultsCache
Method to pin the specified query in the cache, preventing garbage collection.- Specified by:
pin
in interfaceQueryResultsCache
- Parameters:
query
- The query
-
unpin
Description copied from interface:QueryResultsCache
Method to unpin the specified query from the cache, allowing garbage collection.- Specified by:
unpin
in interfaceQueryResultsCache
- Parameters:
query
- The queryparams
- Its params
-
unpin
Description copied from interface:QueryResultsCache
Method to unpin the specified query from the cache, allowing garbage collection.- Specified by:
unpin
in interfaceQueryResultsCache
- Parameters:
query
- The query
-
get
Description copied from interface:QueryResultsCache
Accessor for the results from the cache.- Specified by:
get
in interfaceQueryResultsCache
- Parameters:
queryKey
- The query key- Returns:
- The cached query result ids
-
isEmpty
public boolean isEmpty()Description copied from interface:QueryResultsCache
Accessor for whether the cache is empty.- Specified by:
isEmpty
in interfaceQueryResultsCache
- Returns:
- Whether it is empty.
-
put
Description copied from interface:QueryResultsCache
Method to put an object in the cache.- Specified by:
put
in 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:QueryResultsCache
Accessor for the total number of results in the query cache.- Specified by:
size
in interfaceQueryResultsCache
- Returns:
- Number of queries
-