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

Chapter 10. Eviction


Eviction controls JBoss Cache's memory management by restricting how many nodes are allowed to be stored in memory, and for how long. Memory constraints on servers mean caches cannot grow indefinitely, so eviction needs to occur to prevent out of memory errors. Eviction is most often used alongside Chapter 9, Cache Loaders.

10.1. Design

Eviction in JBoss Cache is designed around four concepts:
  • 1. Collecting statistics
  • 2. Determining which nodes to evict
  • 3. How nodes are evicted
  • 4. Eviction threads.
In addition, Regions play a key role in eviction, as eviction is always configured on a per-region basis so that different subtrees in the cache can have different eviction characteristics.

10.1.1. Collecting Statistics

This is done on the caller's thread whenever anyone interacts with the cache. If eviction is enabled, an EvictionInterceptor is added to the interceptor chain and events are recorded in an event queue. Events are denoted by the EvictionEvent class. Event queues are held on specific Regions so each region has its own event queue.
This aspect of eviction is not configurable, except that the EvictionInterceptor is either added to the interceptor chain or not, depending on whether eviction is enabled.

10.1.2. Determining Which Nodes to Evict

An EvictionAlgorithm implementation processes the eviction queue to decide which nodes to evict. JBoss Cache ships with a number of implementations, including FIFOAlgorithm, LRUAlgorithm, LFUAlgorithm, etc. Each implementation has a corresponding EvictionAlgorithmConfig implementation with configuration details for the algorithm.
Custom EvictionAlgorithm implementations can be provided by implementing the interface or extending one of the provided implementations.
Algorithms are executed by calling its process() method and passing in the event queue to process. This is typically done by calling Region.processEvictionQueues(), which will locate the Algorithm assigned to the region.

10.1.3. How Nodes are Evicted

Once the EvictionAlgorithm decides which nodes to evict, it uses an implementation of EvictionActionPolicy to determine how to evict nodes. This is configurable on a per-region basis, and defaults to DefaultEvictionActionPolicy, which invokes Cache.evict() for each node that needs to be evicted.
JBoss Cache also ships with RemoveOnEvictActionPolicy, which calls Cache.removeNode() for each node that needs to be evicted, instead of Cache.evict().
Custom EvictionActionPolicy implementations can be used as well.

10.1.4. Eviction threads

By default, a single cache-wide eviction thread is used to periodically iterate through registered regions and call Region.processEvictionQueues() on each region. The frequency with which this thread runs can be configured using the wakeUpInterval attribute in the eviction configuration element, and defaults to 5000 milliseconds if not specified.
The eviction thread can be disabled by setting wakeUpInterval to 0. This can be useful if you have your own periodic maintenance thread running and would like to iterate through regions and call Region.processEvictionQueues() yourself.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

Theme

© 2026 Red Hat
맨 위로 이동