Enum CacheType
- java.lang.Object
-
- java.lang.Enum<CacheType>
-
- org.eclipse.persistence.annotations.CacheType
-
- All Implemented Interfaces:
Serializable
,Comparable<CacheType>
public enum CacheType extends Enum<CacheType>
The CacheType enum is used with the Cache annotation for a persistent class. It defines the type of cache (IdentityMap) used for the class. By default the SOFT_WEAK cache type is used.- Since:
- Oracle TopLink 11.1.1.0.0
- Author:
- Guy Pelletier
- See Also:
Cache
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CACHE
A cache identity map maintains a fixed number of objects specified by the application.FULL
Provides full caching and guaranteed identity.HARD_WEAK
Identical to the soft cache weak (SOFT_WEAK) identity map except that it uses hard references in the sub-cache.NONE
WARNING: Does not preserve object identity and does not cache objects.SOFT
Similar to the FULL identity map except that the map holds the objects using soft references.SOFT_WEAK
Similar to the WEAK identity map except that it maintains a most-frequently-used sub-cache.WEAK
Similar to the FULL identity map except that the map holds the objects using weak references.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CacheType
valueOf(String name)
Returns the enum constant of this type with the specified name.static CacheType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FULL
public static final CacheType FULL
Provides full caching and guaranteed identity. Caches all objects and does not remove them. WARNING: This method may be memory intensive when many objects are read. If used on a large data set it will eventually causes an out of memory error.
-
WEAK
public static final CacheType WEAK
Similar to the FULL identity map except that the map holds the objects using weak references. This method allows full garbage collection and guaranteed identity. It will only hold objects that are referenced by the application so may not provide a large caching benefit.
-
SOFT
public static final CacheType SOFT
Similar to the FULL identity map except that the map holds the objects using soft references. This method allows full garbage collection when memory is low and provides full caching and guaranteed identity.
-
SOFT_WEAK
public static final CacheType SOFT_WEAK
Similar to the WEAK identity map except that it maintains a most-frequently-used sub-cache. The size of the sub-cache is proportional to the size of the identity map as specified by @Cache size attribute. The sub-cache uses soft references to ensure that these objects are garbage-collected only if the system is low on memory.
-
HARD_WEAK
public static final CacheType HARD_WEAK
Identical to the soft cache weak (SOFT_WEAK) identity map except that it uses hard references in the sub-cache. Use this identity map if soft references do not behave properly on your platform.
-
CACHE
public static final CacheType CACHE
A cache identity map maintains a fixed number of objects specified by the application. Objects are removed from the cache on a least-recently-used basis. This method allows object identity for the most commonly used objects. WARNING: Furnishes caching and identity, but does not guarantee identity. This cache type is not recommend and should normally not be used, except for objects that have no relationships to them.
-
NONE
public static final CacheType NONE
WARNING: Does not preserve object identity and does not cache objects. This cache type is not recommend and should normally not be used. This cache type should not be used to disable caching, to properly disable caching set the @Cache isolation attribute to ISOLATED.
-
-
Method Detail
-
values
public static CacheType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (CacheType c : CacheType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CacheType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
-