public class MapQueryCache extends Object implements QueryCache, Serializable
QueryCache
interface that stores data in a
non-expiring LRUMap.Modifier and Type | Field and Description |
---|---|
protected Map<String,Map<String,List<?>>> |
cacheGroups |
static int |
DEFAULT_CACHE_SIZE |
Constructor and Description |
---|
MapQueryCache() |
MapQueryCache(int maxSize) |
Modifier and Type | Method and Description |
---|---|
protected String |
cacheName(QueryMetadata metadata) |
void |
clear()
Clears all cache entries.
|
protected Map<String,List<?>> |
createCache(String cacheName) |
protected Map<String,List<?>> |
createIfAbsent(QueryMetadata metadata) |
protected Map<String,List<?>> |
createIfAbsent(String cacheName) |
List |
get(QueryMetadata metadata)
Returns a cached query result for the given QueryMetadata or null if the result is
not cached or is expired.
|
List |
get(QueryMetadata metadata,
QueryCacheEntryFactory factory)
Returns a non-null cached value.
|
protected Map<String,List<?>> |
getCache(String name) |
void |
put(QueryMetadata metadata,
List results) |
void |
remove(String key)
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()
Returns the number of entries currently in the cache, including expired but not
removed entries.
|
public static final int DEFAULT_CACHE_SIZE
public MapQueryCache()
public MapQueryCache(int maxSize)
public List get(QueryMetadata metadata)
QueryCache
get
in interface QueryCache
public List get(QueryMetadata metadata, QueryCacheEntryFactory factory)
QueryCacheEntryFactory.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.get
in interface QueryCache
public void put(QueryMetadata metadata, List results)
put
in interface QueryCache
public void remove(String key)
QueryCache
remove
in interface QueryCache
public void removeGroup(String groupKey)
QueryCache
removeGroup
in interface QueryCache
public void removeGroup(String groupKey, Class<?> keyType, Class<?> valueType)
QueryCache
removeGroup
in interface QueryCache
QueryCache.removeGroup(String)
public void clear()
QueryCache
clear
in interface QueryCache
public int size()
QueryCache
size
in interface QueryCache
protected Map<String,List<?>> createIfAbsent(QueryMetadata metadata)
protected String cacheName(QueryMetadata metadata)
Copyright © 2001–2017 Apache Cayenne. All rights reserved.