Package org.apache.cayenne.cache
Class MapQueryCache
java.lang.Object
org.apache.cayenne.cache.MapQueryCache
- All Implemented Interfaces:
Serializable
,QueryCache
A default implementation of the
QueryCache
interface that stores data in a
non-expiring LRUMap.- Since:
- 3.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
cacheName
(QueryMetadata metadata) void
clear()
Clears all cache entries.createCache
(String cacheName) createIfAbsent
(String cacheName) createIfAbsent
(QueryMetadata metadata) get
(QueryMetadata metadata) Returns a cached query result for the given QueryMetadata or null if the result is not cached or is expired.get
(QueryMetadata metadata, QueryCacheEntryFactory factory) Returns a non-null cached value.void
put
(QueryMetadata metadata, List results) void
Removes a single entry from cache.void
removeGroup
(String groupKey) Removes a group of entries identified by group key.void
removeGroup
(String groupKey, Class<?> keyType, Class<?> valueType) Removes a group of entries identified by group key.int
size()
-
Field Details
-
DEFAULT_CACHE_SIZE
public static final int DEFAULT_CACHE_SIZE- See Also:
-
cacheGroups
-
-
Constructor Details
-
MapQueryCache
public MapQueryCache() -
MapQueryCache
public MapQueryCache(int maxSize)
-
-
Method Details
-
get
Description copied from interface:QueryCache
Returns a cached query result for the given QueryMetadata or null if the result is not cached or is expired.- Specified by:
get
in interfaceQueryCache
-
get
Returns 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:
get
in interfaceQueryCache
-
put
- Specified by:
put
in interfaceQueryCache
-
remove
Description copied from interface:QueryCache
Removes a single entry from cache.- Specified by:
remove
in interfaceQueryCache
-
removeGroup
Description copied from interface:QueryCache
Removes 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:
removeGroup
in interfaceQueryCache
-
removeGroup
Description copied from interface:QueryCache
Removes a group of entries identified by group key. Can be used if cache provider supports strictly typed caches.- Specified by:
removeGroup
in interfaceQueryCache
- See Also:
-
clear
public void clear()Description copied from interface:QueryCache
Clears all cache entries.- Specified by:
clear
in interfaceQueryCache
-
size
public int size() -
createIfAbsent
-
createIfAbsent
-
createCache
-
getCache
-
cacheName
-