Package org.datanucleus.cache
Class SoftRefCache
java.lang.Object
org.datanucleus.cache.SoftRefCache
- All Implemented Interfaces:
Map<Object,
,DNStateManager> Level1Cache
Level 1 Cache using Soft referenced objects in a Map.
If map entry value object is not actively being used, i.e. no other object has a strong reference to it,
it may become garbage collected at the discretion of the garbage collector (typically if the VM is low on memory).
If this happens, the entry in the SoftValueMap
corresponding to the value object will also be removed.
- See Also:
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
private Map
<Object, DNStateManager> private Map
<CacheUniqueKey, DNStateManager> Fields inherited from interface org.datanucleus.cache.Level1Cache
NONE_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object id) boolean
containsValue
(Object value) entrySet()
getUnique
(CacheUniqueKey key) Method to retrieve StateManager for the specified unique key.boolean
isEmpty()
keySet()
put
(Object id, DNStateManager sm) void
putUnique
(CacheUniqueKey key, DNStateManager sm) Method to store a StateManager for this unique key.int
size()
values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
NAME
- See Also:
-
softCache
-
softCacheUnique
-
-
Constructor Details
-
SoftRefCache
public SoftRefCache()
-
-
Method Details
-
put
- Specified by:
put
in interfaceMap<Object,
DNStateManager>
-
get
- Specified by:
get
in interfaceMap<Object,
DNStateManager>
-
containsKey
- Specified by:
containsKey
in interfaceMap<Object,
DNStateManager>
-
remove
- Specified by:
remove
in interfaceMap<Object,
DNStateManager>
-
clear
public void clear()- Specified by:
clear
in interfaceMap<Object,
DNStateManager>
-
containsValue
- Specified by:
containsValue
in interfaceMap<Object,
DNStateManager>
-
entrySet
- Specified by:
entrySet
in interfaceMap<Object,
DNStateManager>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceMap<Object,
DNStateManager>
-
keySet
- Specified by:
keySet
in interfaceMap<Object,
DNStateManager>
-
putAll
- Specified by:
putAll
in interfaceMap<Object,
DNStateManager>
-
size
public int size()- Specified by:
size
in interfaceMap<Object,
DNStateManager>
-
values
- Specified by:
values
in interfaceMap<Object,
DNStateManager>
-
getUnique
Description copied from interface:Level1Cache
Method to retrieve StateManager for the specified unique key.- Specified by:
getUnique
in interfaceLevel1Cache
- Parameters:
key
- Unique key- Returns:
- StateManager if one is cached for this unique key
-
putUnique
Description copied from interface:Level1Cache
Method to store a StateManager for this unique key.- Specified by:
putUnique
in interfaceLevel1Cache
- Parameters:
key
- The unique keysm
- StateManager- Returns:
- The previous StateManager for this unique key if one was present, otherwise null
-