Package org.apache.cayenne.cache
Class MapQueryCache
java.lang.Object
org.apache.cayenne.cache.MapQueryCache
- All Implemented Interfaces:
- Serializable,- QueryCache
public class MapQueryCache extends Object implements QueryCache, Serializable
A default implementation of the 
QueryCache interface that stores data in a
 non-expiring LRUMap.- Since:
- 3.0
- See Also:
- Serialized Form
- 
Field SummaryFields Modifier and Type Field Description protected Map<String,Map<String,List<?>>>cacheGroupsstatic intDEFAULT_CACHE_SIZE
- 
Constructor SummaryConstructors Constructor Description MapQueryCache()MapQueryCache(int maxSize)
- 
Method SummaryModifier and Type Method Description protected StringcacheName(QueryMetadata metadata)voidclear()Clears all cache entries.protected Map<String,List<?>>createCache(String cacheName)protected Map<String,List<?>>createIfAbsent(String cacheName)protected Map<String,List<?>>createIfAbsent(QueryMetadata metadata)Listget(QueryMetadata metadata)Returns a cached query result for the given QueryMetadata or null if the result is not cached or is expired.Listget(QueryMetadata metadata, QueryCacheEntryFactory factory)Returns a non-null cached value.protected Map<String,List<?>>getCache(String name)voidput(QueryMetadata metadata, List results)voidremove(String key)Removes a single entry from cache.voidremoveGroup(String groupKey)Removes a group of entries identified by group key.voidremoveGroup(String groupKey, Class<?> keyType, Class<?> valueType)Removes a group of entries identified by group key.intsize()
- 
Field Details- 
DEFAULT_CACHE_SIZEpublic static final int DEFAULT_CACHE_SIZE- See Also:
- Constant Field Values
 
- 
cacheGroups
 
- 
- 
Constructor Details- 
MapQueryCachepublic MapQueryCache()
- 
MapQueryCachepublic MapQueryCache(int maxSize)
 
- 
- 
Method Details- 
getDescription copied from interface:QueryCacheReturns a cached query result for the given QueryMetadata or null if the result is not cached or is expired.- Specified by:
- getin interface- QueryCache
 
- 
getReturns a non-null cached value. If it is not present in the cache, it is obtained by callingQueryCacheEntryFactory.createObject()without blocking the cache. As a result there is a potential of multiple threads to be updating cache in parallel - this wouldn't lead to corruption of the cache, but can be suboptimal.- Specified by:
- getin interface- QueryCache
 
- 
put- Specified by:
- putin interface- QueryCache
 
- 
removeDescription copied from interface:QueryCacheRemoves a single entry from cache.- Specified by:
- removein interface- QueryCache
 
- 
removeGroupDescription copied from interface:QueryCacheRemoves a group of entries identified by group key. Note that depending on implementation this method may either actively remove the entries belonging to the group or just mark them as expired, so that they are refreshed on the next access. In the former case the cache size would shrink, but in the later the cache size will not change after calling this method.- Specified by:
- removeGroupin interface- QueryCache
 
- 
removeGroupDescription copied from interface:QueryCacheRemoves a group of entries identified by group key. Can be used if cache provider supports strictly typed caches.- Specified by:
- removeGroupin interface- QueryCache
- See Also:
- QueryCache.removeGroup(String)
 
- 
clearpublic void clear()Description copied from interface:QueryCacheClears all cache entries.- Specified by:
- clearin interface- QueryCache
 
- 
sizepublic int size()
- 
createIfAbsent
- 
createIfAbsent
- 
createCache
- 
getCache
- 
cacheName
 
-