public class PreparedQueryCacheImpl extends Object implements PreparedQueryCache
prepared queries
.Modifier and Type | Class and Description |
---|---|
static class |
PreparedQueryCacheImpl.StrongExclusion
Strong exclusion.
|
static class |
PreparedQueryCacheImpl.WeakExclusion
Weak exclusion.
|
PreparedQueryCache.Exclusion
Constructor and Description |
---|
PreparedQueryCacheImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addExclusionPattern(String pattern)
Adds a pattern for exclusion.
|
boolean |
cache(PreparedQuery q)
Cache the given query keyed by its identifier.
|
void |
clear()
Clears all cached queries.
|
void |
endConfiguration()
Invoked upon completion of bean property configuration for this object.
|
PreparedQuery |
get(String id)
Get the PreparedQuery with the given identifier if it exists. null
otherwise.
|
int |
getCacheSize() |
boolean |
getEnableStatistics()
Affirm if statistics is gathered.
|
List<PreparedQueryCache.Exclusion> |
getExcludes()
Gets the exclusion patterns.
|
Map<String,String> |
getMapView()
Get a map view of the cached queries indexed by identifier.
|
QueryStatistics<String> |
getStatistics()
Gets the simple statistics for executed queries.
|
PreparedQuery |
initialize(String key,
Object result)
Initialize the cached Prepared Query registered with the given
key earlier by the given execution result.
|
boolean |
invalidate(String id)
Remove the PreparedQuery with the given identifier from this cache.
|
Boolean |
isCachable(String id)
Affirms if a PreparedQuery can be cached against the given key.
|
PreparedQueryCache.Exclusion |
isExcluded(String id)
Returns the exclusion status of if the given query key.
|
protected void |
lock(boolean readOnly)
Note: Care needs to be taken so that a read lock is never held while requesting a write lock.
|
PreparedQuery |
markUncachable(String id,
PreparedQueryCache.Exclusion exclusion)
Marks the given key as not amenable to caching.
|
Boolean |
register(String id,
Query query,
FetchConfiguration hints)
Register the given query for caching against the given key if it has not
already been cached.
|
void |
removeExclusionPattern(String pattern)
Removes a pattern for exclusion.
|
void |
setConfiguration(Configuration conf)
Invoked prior to setting bean properties.
|
void |
setEnableStatistics(boolean enable)
Enable/disable gathering of statistics.
|
void |
setExcludes(String excludes)
Sets one or more exclusion regular expression patterns separated by
semicolon.
|
void |
setMaxCacheSize(int size) |
void |
startConfiguration()
Invoked before bean property configuration is begun on this object.
|
protected void |
unlock(boolean readOnly) |
public Boolean register(String id, Query query, FetchConfiguration hints)
PreparedQueryCache
register
in interface PreparedQueryCache
public Map<String,String> getMapView()
PreparedQueryCache
getMapView
in interface PreparedQueryCache
public boolean cache(PreparedQuery q)
cache
in interface PreparedQueryCache
#markUncachable(String)
,
PreparedQueryCache.setExcludes(String)
,
PreparedQueryCache.addExclusionPattern(String)
public PreparedQuery initialize(String key, Object result)
PreparedQueryCache
initialize
in interface PreparedQueryCache
key
- the key used during registrationresult
- an opaque instance carrying the execution result
of the original query.public boolean invalidate(String id)
PreparedQueryCache
invalidate
in interface PreparedQueryCache
public PreparedQuery get(String id)
PreparedQueryCache
get
in interface PreparedQueryCache
public Boolean isCachable(String id)
PreparedQueryCache
isCachable
in interface PreparedQueryCache
public PreparedQuery markUncachable(String id, PreparedQueryCache.Exclusion exclusion)
PreparedQueryCache
markUncachable
in interface PreparedQueryCache
id
- is the key to be excludedexclusion
- directs whether exclusion is irreversible or not.public PreparedQueryCache.Exclusion isExcluded(String id)
PreparedQueryCache
isExcluded
in interface PreparedQueryCache
public void setExcludes(String excludes)
PreparedQueryCache
setExcludes
in interface PreparedQueryCache
public List<PreparedQueryCache.Exclusion> getExcludes()
PreparedQueryCache
getExcludes
in interface PreparedQueryCache
public void addExclusionPattern(String pattern)
addExclusionPattern
in interface PreparedQueryCache
public void removeExclusionPattern(String pattern)
removeExclusionPattern
in interface PreparedQueryCache
PreparedQueryCache.markUncachable(String, Exclusion)
public QueryStatistics<String> getStatistics()
PreparedQueryCache
getStatistics
in interface PreparedQueryCache
protected void lock(boolean readOnly)
readOnly
- - If true, a read lock will be acquired. Else a write lock will be acquired.protected void unlock(boolean readOnly)
readOnly
- - If true, the read lock will be released. Else a write lock will be released.public void clear()
PreparedQueryCache
clear
in interface PreparedQueryCache
public void setEnableStatistics(boolean enable)
PreparedQueryCache
setEnableStatistics
in interface PreparedQueryCache
public boolean getEnableStatistics()
PreparedQueryCache
getEnableStatistics
in interface PreparedQueryCache
public void setMaxCacheSize(int size)
public int getCacheSize()
public void setConfiguration(Configuration conf)
Configurable
setConfiguration
in interface Configurable
public void startConfiguration()
Configurable
startConfiguration
in interface Configurable
public void endConfiguration()
Configurable
endConfiguration
in interface Configurable
Copyright © 2006–2020 Apache Software Foundation. All rights reserved.