Enum Class RemovalCause

java.lang.Object
java.lang.Enum<RemovalCause>
cloud.opencode.base.cache.model.RemovalCause
All Implemented Interfaces:
Serializable, Comparable<RemovalCause>, Constable

public enum RemovalCause extends Enum<RemovalCause>
Cache Entry Removal Cause - Enum indicating why a cache entry was removed 缓存条目移除原因 - 表示缓存条目被移除原因的枚举

Provides detailed information about cache entry removal for monitoring and debugging.

提供缓存条目移除的详细信息,用于监控和调试。

Features | 主要功能:

  • Explicit removal (manual invalidation) - 显式移除(手动失效)
  • Replaced by new value - 被新值替换
  • Expired (TTL/TTI) - 过期(TTL/TTI)
  • Evicted due to size limit - 因容量限制淘汰
  • Collected by GC (weak/soft reference) - 被 GC 回收(弱/软引用)

Usage Examples | 使用示例:

cache.removalListener((key, value, cause) -> {
    if (cause.wasEvicted()) {
        log.info("Entry evicted: key={}, cause={}", key, cause);
    }
});

Security | 安全性:

  • Thread-safe: Yes (immutable enum) - 线程安全: 是(不可变枚举)
  • Null-safe: Yes - 空值安全: 是
Since:
JDK 25, opencode-base-cache V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Entry was collected by garbage collector (weak/soft reference) 被垃圾回收器回收(弱引用/软引用)
    Entry expired (TTL or TTI) 过期移除(TTL 或 TTI)
    Entry was explicitly removed by user (invalidate) 用户显式移除(invalidate 调用)
    Entry was replaced by a new value 被新值替换
    Entry was evicted due to size/weight limit 因容量/权重限制被淘汰
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this class with the specified name.
    static RemovalCause[]
    Returns an array containing the constants of this enum class, in the order they are declared.
    boolean
    Check if entry was passively evicted (not manually removed) 检查是否为被动淘汰(非手动移除)
    boolean
    Check if entry was explicitly removed 检查是否为显式移除

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • EXPLICIT

      public static final RemovalCause EXPLICIT
      Entry was explicitly removed by user (invalidate) 用户显式移除(invalidate 调用)
    • REPLACED

      public static final RemovalCause REPLACED
      Entry was replaced by a new value 被新值替换
    • EXPIRED

      public static final RemovalCause EXPIRED
      Entry expired (TTL or TTI) 过期移除(TTL 或 TTI)
    • SIZE

      public static final RemovalCause SIZE
      Entry was evicted due to size/weight limit 因容量/权重限制被淘汰
    • COLLECTED

      public static final RemovalCause COLLECTED
      Entry was collected by garbage collector (weak/soft reference) 被垃圾回收器回收(弱引用/软引用)
  • Method Details

    • values

      public static RemovalCause[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static RemovalCause valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • wasEvicted

      public boolean wasEvicted()
      Check if entry was passively evicted (not manually removed) 检查是否为被动淘汰(非手动移除)
      Returns:
      true if passively evicted | 被动淘汰返回 true
    • wasExplicit

      public boolean wasExplicit()
      Check if entry was explicitly removed 检查是否为显式移除
      Returns:
      true if explicitly removed | 显式移除返回 true