Este conteúdo não está disponível no idioma selecionado.
2.3. Using Eviction
eviction /> element is used to enable eviction without any strategy or maximum entries settings, the following default values are used:
- Strategy: If no eviction strategy is specified,
EvictionStrategy.NONEis assumed as a default. - size: If no value is specified, the
sizevalue is set to-1, which allows unlimited entries.
2.3.1. Initialize Eviction Copiar o linkLink copiado para a área de transferência!
size attributes value to a number greater than zero. Adjust the value set for size to discover the optimal value for your configuration. It is important to remember that if too large a value is set for size, Red Hat JBoss Data Grid runs out of memory.
Procedure 2.1. Initialize Eviction
Add the Eviction Tag
Add the <eviction> tag to your project's <cache> tags as follows:<eviction />
<eviction />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Eviction Strategy
Set thestrategyvalue to set the eviction strategy employed. Possible values areLRU,UNORDEREDandLIRS(orNONEif no eviction is required). The following is an example of this step:<eviction strategy="LRU" />
<eviction strategy="LRU" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Maximum Size to use for Eviction
Set the maximum number of entries allowed in memory by defining thesizeelement. The default value is-1for unlimited entries. The following demonstrates this step:<eviction strategy="LRU" size="200" />
<eviction strategy="LRU" size="200" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Eviction is configured for the target cache.
2.3.2. Eviction Configuration Examples Copiar o linkLink copiado para a área de transferência!
<eviction strategy="LRU" size="2000"/>
<eviction strategy="LRU" size="2000"/>
2.3.3. Utilizing Memory Based Eviction Copiar o linkLink copiado para a área de transferência!
Only keys and values that are stored as primitives, primitive wrappers (such as java.lang.Integer), java.lang.String instances, or an Array of these values may be used with memory based eviction.
store-as-binary must be enabled on the cache, or the data from the custom class may be serialized, storing it in a byte array.
Memory based eviction is only supported with the LRU eviction strategy.
This eviction method may be used by defining MEMORY as the eviction type, as seen in the following example:
<local-cache name="local">
<eviction size="10000000000" strategy="LRU" type="MEMORY"/>
</local-cache>
<local-cache name="local">
<eviction size="10000000000" strategy="LRU" type="MEMORY"/>
</local-cache>