Package org.datanucleus.cache
Class StrongRefCache
java.lang.Object
org.datanucleus.cache.StrongRefCache
- All Implemented Interfaces:
Map<Object,
,DNStateManager> Level1Cache
Implementation of a Level 1 cache keeping strong references to the objects.
This means that objects are not garbage collected, and have to be removed directly by calls to remove().
This differs from the WeakRefCache/SoftRefCache which do not guarantee to retain objects.
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map
<Object, DNStateManager> private Map
<CacheUniqueKey, DNStateManager> static final String
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:
-
cache
-
cacheUnique
-
-
Constructor Details
-
StrongRefCache
public StrongRefCache()
-
-
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
-