public interface FinderCache<K,V,R> extends Configurable
finder queries
.
A finder query is a query to find instance of a given class by its primary
identity. This cache maintains finder queries by generic identifier of
parameterized type K.
A cached query by an identifier of parameterized type K.
A query can be cached by an identifier and value represented by parameterized
type V. Caching results in creating a new instance of FinderQuery FQ from the
value V such that FQ can be executed to return a result of parameterized type
R. A request to cache may not be successful if this cache determines the
value V to be not cachable.
Both get() and put() operations can be controlled by the hints associated
with FetchConfiguration.
The target database query FQ associated to a cached finder query F
may depend upon query execution context such as fetch plan or
lock group. This cache, by design, does not monitor the context or
automatically invalidate an entry when the original query F is executed
with context parameters that affect the target query FQ.
The user must notify this receiver to invalidate a cached entry when
execution context changes in a way that will modify the resultant database
language query FQ.
One of the built-in mechanism (available in JPA facade) is to set query hints
to either invalidate the query entirely or ignore the cached version for the
current execution.QueryHints.HINT_IGNORE_FINDER
,
QueryHints.HINT_INVALIDATE_FINDER
,
This cache allows customization of whether a query can be cached or not
via either explicit marking of certain classes as non-cachable (which is
irreversible) or addition/removal of exclusion patterns (which is reversible)
Modifier and Type | Method and Description |
---|---|
void |
addExclusionPattern(String pattern)
Adds the given pattern to the list of excluded patterns.
|
FinderQuery<K,V,R> |
cache(K key,
V value,
FetchConfiguration fetch)
Cache a FinderQuery for the given key and value.
|
FinderQuery<K,V,R> |
get(K key,
FetchConfiguration fetch)
Get the FinderQuery for the given key.
|
List<String> |
getExcludes()
Gets the excluded stringified keys.
|
Map<String,String> |
getMapView()
Get a map view of the cached entries as strings.
|
QueryStatistics<K> |
getStatistics()
Gets the simple statistics for executed finder queries.
|
boolean |
invalidate(K key)
Remove the FinderQuery for the given key from this cache.
|
boolean |
isExcluded(K key)
Affirms if the given key matches any of the exclusion patterns.
|
FinderQuery<K,V,R> |
markUncachable(K key)
Marks the given key as not amenable to caching.
|
void |
removeExclusionPattern(String pattern)
Removes the given pattern from the list of excluded patterns.
|
endConfiguration, setConfiguration, startConfiguration
FinderQuery<K,V,R> get(K key, FetchConfiguration fetch)
key
- for which the finder is looked upfecth
- may contain hints to control lookup operationFinderQuery<K,V,R> cache(K key, V value, FetchConfiguration fetch)
key
- for which the finder is cached.value
- used to construct the finder queryfetch
- may contain hints to control cache operation.boolean invalidate(K key)
FinderQuery<K,V,R> markUncachable(K key)
boolean isExcluded(K key)
void addExclusionPattern(String pattern)
void removeExclusionPattern(String pattern)
QueryStatistics<K> getStatistics()
Copyright © 2006–2019 Apache Software Foundation. All rights reserved.