Package org.apache.openjpa.datacache
Interface QueryCache
- 
- All Superinterfaces:
 Closeable,TypesChangedListener
- All Known Implementing Classes:
 AbstractQueryCache,ConcurrentQueryCache,DelegatingQueryCache
public interface QueryCache extends TypesChangedListener, Closeable
Interface that must be implemented by any level 2 query cache used by OpenJPA. These methods should be threadsafe. Most query cache implementations will probably implementConfigurableto receive a handle to the system configuration on construction.- Since:
 - 0.2.5
 - Author:
 - Patrick Linskey
 
 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddTypesChangedListener(TypesChangedListener listen)Add a new types event listener to this cache.voidclear()Remove all data from this cache.voidclose()Free the resources used by this cache.QueryResultget(QueryKey qk)Return a list of oids for the given query key.QueryStatistics<QueryKey>getStatistics()Gets the simple statistics for query results.voidinitialize(DataCacheManager manager)Initialize any resources associated with the givenDataCacheManager.booleanpin(QueryKey qk)Pin the value stored underqkinto the cache.QueryResultput(QueryKey qk, QueryResult oids)Set the list of OIDs for the given query key.QueryResultremove(QueryKey qk)Remove the value stored under the given query key.booleanremoveTypesChangedListener(TypesChangedListener listen)Remove an types event listener from this cache.booleanunpin(QueryKey qk)Unpin the value stored underkeyinto the cache.voidwriteLock()Obtain a write lock on the cache.voidwriteUnlock()Release the write lock on the cache.- 
Methods inherited from interface org.apache.openjpa.datacache.TypesChangedListener
onTypesChanged 
 - 
 
 - 
 
- 
- 
Method Detail
- 
initialize
void initialize(DataCacheManager manager)
Initialize any resources associated with the givenDataCacheManager.- Since:
 - 0.4.1
 
 
- 
get
QueryResult get(QueryKey qk)
Return a list of oids for the given query key. This is an unmodifiable list.- Returns:
 - The query results matching the given key, or null if none
 
 
- 
put
QueryResult put(QueryKey qk, QueryResult oids)
Set the list of OIDs for the given query key. A reference to the given list will be stored in the query cache, so the list should not be modified after invoking this method.- Returns:
 - The previously cached value, or 
nullif the key was not previously cached. SeeMap.put(K, V)for more information. 
 
- 
remove
QueryResult remove(QueryKey qk)
Remove the value stored under the given query key. This method is typically not invoked directly from outside theQueryCacheclass. Instead, the cache should be updated by implementingRemoteCommitListener, which will result in all queries that may be invalid being dropped.- Returns:
 - The previously cached value, or 
nullif the key was not previously cached. SeeMap.remove(java.lang.Object)for more information. 
 
- 
clear
void clear()
Remove all data from this cache. 
- 
pin
boolean pin(QueryKey qk)
Pin the value stored underqkinto the cache. This method guarantees thatqk's value will not be expired if the cache exceeds its capacity. It causes this data to be ignored when determining whether or not the cache is full, effectively increasing the total amount of data stored in the cache. This method does not affect the behavior ofremove(org.apache.openjpa.datacache.QueryKey)orTypesChangedListener.onTypesChanged(org.apache.openjpa.datacache.TypesChangedEvent).- Returns:
 trueifkey's value was pinned into the cache;falseif the key is not in the cache.
 
- 
unpin
boolean unpin(QueryKey qk)
Unpin the value stored underkeyinto the cache. This method reverses a previous invocation ofpin(org.apache.openjpa.datacache.QueryKey). This method does not remove anything from the cache; it merely makeskey's value a candidate for flushing from the cache.- Returns:
 trueifkey's value was unpinned from the cache;falseif the key is not in the cache.
 
- 
writeLock
void writeLock()
Obtain a write lock on the cache. 
- 
writeUnlock
void writeUnlock()
Release the write lock on the cache. 
- 
addTypesChangedListener
void addTypesChangedListener(TypesChangedListener listen)
Add a new types event listener to this cache.- Since:
 - 0.3.3
 
 
- 
removeTypesChangedListener
boolean removeTypesChangedListener(TypesChangedListener listen)
Remove an types event listener from this cache.- Since:
 - 0.3.3
 
 
- 
close
void close()
Free the resources used by this cache. 
- 
getStatistics
QueryStatistics<QueryKey> getStatistics()
Gets the simple statistics for query results. If the statistics gathering is disabled, an empty statistics is returned.- Since:
 - 2.1.0
 
 
 - 
 
 -