이 콘텐츠는 선택한 언어로 제공되지 않습니다.

2.3. Using Eviction


In Red Hat JBoss Data Grid, eviction is disabled by default. If an empty <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.NONE is assumed as a default.
  • size: If no value is specified, the size value is set to -1, which allows unlimited entries.

2.3.1. Initialize Eviction

To initialize eviction, set the eviction element's 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.
The following procedure outlines the steps to initialize eviction in JBoss Data Grid:

Procedure 2.1. Initialize Eviction

  1. Add the Eviction Tag

    Add the <eviction> tag to your project's <cache> tags as follows:
    <eviction />
    Copy to Clipboard Toggle word wrap
  2. Set the Eviction Strategy

    Set the strategy value to set the eviction strategy employed. Possible values are LRU, UNORDERED and LIRS (or NONE if no eviction is required). The following is an example of this step:
    <eviction strategy="LRU" />
    Copy to Clipboard Toggle word wrap
  3. Set the Maximum Size to use for Eviction

    Set the maximum number of entries allowed in memory by defining the size element. The default value is -1 for unlimited entries. The following demonstrates this step:
    <eviction strategy="LRU" size="200" />
    Copy to Clipboard Toggle word wrap
Result

Eviction is configured for the target cache.

2.3.2. Eviction Configuration Examples

Eviction may be configured in Red Hat JBoss Data Grid programmatically or via the XML file. Eviction configuration is done on a per-cache basis.
A sample XML configuration for is as follows:
<eviction strategy="LRU" size="2000"/>
Copy to Clipboard Toggle word wrap

2.3.3. Utilizing Memory Based Eviction

Red Hat JBoss Data Grid 7 introduced memory based eviction, allowing eviction of entries based on memory usage of the entries instead of the number of entries. This can be particularly useful if the entries vary in size.
Key/Value Limitations

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.

Due to this limitation if custom classes are used then either 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.
Compatibility mode prevents serialization into byte arrays, and as such these two features are mutually exclusive.
Eviction Strategy Limitations

Memory based eviction is only supported with the LRU eviction strategy.

Enabling Memory Based Eviction

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>
Copy to Clipboard Toggle word wrap

2.3.4. Eviction and Passivation

To ensure that a single copy of an entry remains, either in memory or in a cache store, use passivation in conjunction with eviction.
The primary reason to use passivation instead of a normal cache store is that updating entries require less resources when passivation is in use. This is because passivation does not require an update to the cache store.
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat