Enum CacheType
- All Implemented Interfaces:
Serializable
,Comparable<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.
- See Also:
- Author:
- Guy Pelletier
-
Enum Constant Summary
Enum ConstantDescriptionA cache identity map maintains a fixed number of objects specified by the application.Provides full caching and guaranteed identity.Identical to the soft cache weak (SOFT_WEAK) identity map except that it uses hard references in the sub-cache.WARNING: Does not preserve object identity and does not cache objects.Similar to the FULL identity map except that the map holds the objects using soft references.Similar to the WEAK identity map except that it maintains a most-frequently-used sub-cache.Similar to the FULL identity map except that the map holds the objects using weak references. -
Method Summary
-
Enum Constant Details
-
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
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
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
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
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
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
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 Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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
-