Package org.alfresco.repo.cache
Class MemoryCache<K extends Serializable,V>
java.lang.Object
org.alfresco.repo.cache.MemoryCache<K,V>
- All Implemented Interfaces:
SimpleCache<K,
V>
A cache backed by a simple
ConcurrentHashMap
.
Note: This cache is not transaction-safe. Use it for tests or wrap it appropriately.
- Since:
- 3.2
- Author:
- Derek Hulley
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
MemoryCache
public MemoryCache()
-
-
Method Details
-
contains
- Specified by:
contains
in interfaceSimpleCache<K extends Serializable,
V> - Parameters:
key
- the cache key to check up on- Returns:
- Returns true if there is a cache entry, regardless of whether the value itself is null
-
getKeys
- Specified by:
getKeys
in interfaceSimpleCache<K extends Serializable,
V>
-
get
- Specified by:
get
in interfaceSimpleCache<K extends Serializable,
V> - Parameters:
key
- K- Returns:
- Returns the value associated with the key. It will be null if the value is null or if the cache doesn't have an entry.
-
put
Description copied from interface:SimpleCache
Set the value to store for a given key. Be sure to useremove
if cache entries need to be removed as the cache implementations must treat a null value as a first class object in exactly the same way as aMap
will allow storage and retrieval of null values.- Specified by:
put
in interfaceSimpleCache<K extends Serializable,
V> - Parameters:
key
- the key against which to store the valuevalue
- the value to store. null is allowed.
-
remove
Description copied from interface:SimpleCache
Removes the cache entry whether or not the value stored against it is null.- Specified by:
remove
in interfaceSimpleCache<K extends Serializable,
V> - Parameters:
key
- the key value to remove
-
clear
public void clear()- Specified by:
clear
in interfaceSimpleCache<K extends Serializable,
V>
-