Record Class DistributedCacheStats

java.lang.Object
java.lang.Record
cloud.opencode.base.cache.distributed.DistributedCacheStats
Record Components:
hitCount - the number of cache hits - 缓存命中次数
missCount - the number of cache misses - 缓存未命中次数
loadCount - the number of load operations - 加载操作次数
loadSuccessCount - the number of successful loads - 成功加载次数
loadFailureCount - the number of failed loads - 失败加载次数
totalLoadTime - the total load time - 总加载时间
evictionCount - the number of evictions - 淘汰次数
requestCount - the total number of requests - 总请求次数
connectionCount - the number of active connections - 活跃连接数
memoryUsed - the memory used by the cache - 缓存使用的内存
keyCount - the number of keys in the cache - 缓存中的键数量
avgLatency - the average operation latency - 平均操作延迟
p99Latency - the 99th percentile latency - 99分位延迟
lastResetTime - the last statistics reset time - 上次统计重置时间

Features | 主要功能:

  • Hit/miss statistics - 命中/未命中统计
  • Latency tracking (avg, P99) - 延迟跟踪(平均、P99)
  • Connection and memory metrics - 连接和内存指标
  • Rate calculations - 比率计算

Usage Examples | 使用示例:

DistributedCacheStats stats = distributedCache.stats();
double hitRate = stats.hitRate();
long keyCount = stats.keyCount();

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
  • Null-safe: Yes - 空值安全: 是

public record DistributedCacheStats(long hitCount, long missCount, long loadCount, long loadSuccessCount, long loadFailureCount, Duration totalLoadTime, long evictionCount, long requestCount, int connectionCount, long memoryUsed, long keyCount, Duration avgLatency, Duration p99Latency, Instant lastResetTime) extends Record
Statistics for Distributed Cache 分布式缓存统计信息
Since:
JDK 25, opencode-base-cache V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • DistributedCacheStats

      public DistributedCacheStats(long hitCount, long missCount, long loadCount, long loadSuccessCount, long loadFailureCount, Duration totalLoadTime, long evictionCount, long requestCount, int connectionCount, long memoryUsed, long keyCount, Duration avgLatency, Duration p99Latency, Instant lastResetTime)
      Creates an instance of a DistributedCacheStats record class.
      Parameters:
      hitCount - the value for the hitCount record component
      missCount - the value for the missCount record component
      loadCount - the value for the loadCount record component
      loadSuccessCount - the value for the loadSuccessCount record component
      loadFailureCount - the value for the loadFailureCount record component
      totalLoadTime - the value for the totalLoadTime record component
      evictionCount - the value for the evictionCount record component
      requestCount - the value for the requestCount record component
      connectionCount - the value for the connectionCount record component
      memoryUsed - the value for the memoryUsed record component
      keyCount - the value for the keyCount record component
      avgLatency - the value for the avgLatency record component
      p99Latency - the value for the p99Latency record component
      lastResetTime - the value for the lastResetTime record component
  • Method Details

    • empty

      public static DistributedCacheStats empty()
      Creates an empty stats instance. 创建空的统计实例。
      Returns:
      empty stats - 空统计
    • hitRate

      public double hitRate()
      Gets the hit rate. 获取命中率。
      Returns:
      the hit rate (0.0 to 1.0) - 命中率
    • missRate

      public double missRate()
      Gets the miss rate. 获取未命中率。
      Returns:
      the miss rate (0.0 to 1.0) - 未命中率
    • loadSuccessRate

      public double loadSuccessRate()
      Gets the load success rate. 获取加载成功率。
      Returns:
      the load success rate - 加载成功率
    • averageLoadTime

      public Duration averageLoadTime()
      Gets the average load time. 获取平均加载时间。
      Returns:
      the average load time - 平均加载时间
    • builder

      public static DistributedCacheStats.Builder builder()
      Creates a builder for DistributedCacheStats. 创建 DistributedCacheStats 构建器。
      Returns:
      the builder - 构建器
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hitCount

      public long hitCount()
      Returns the value of the hitCount record component.
      Returns:
      the value of the hitCount record component
    • missCount

      public long missCount()
      Returns the value of the missCount record component.
      Returns:
      the value of the missCount record component
    • loadCount

      public long loadCount()
      Returns the value of the loadCount record component.
      Returns:
      the value of the loadCount record component
    • loadSuccessCount

      public long loadSuccessCount()
      Returns the value of the loadSuccessCount record component.
      Returns:
      the value of the loadSuccessCount record component
    • loadFailureCount

      public long loadFailureCount()
      Returns the value of the loadFailureCount record component.
      Returns:
      the value of the loadFailureCount record component
    • totalLoadTime

      public Duration totalLoadTime()
      Returns the value of the totalLoadTime record component.
      Returns:
      the value of the totalLoadTime record component
    • evictionCount

      public long evictionCount()
      Returns the value of the evictionCount record component.
      Returns:
      the value of the evictionCount record component
    • requestCount

      public long requestCount()
      Returns the value of the requestCount record component.
      Returns:
      the value of the requestCount record component
    • connectionCount

      public int connectionCount()
      Returns the value of the connectionCount record component.
      Returns:
      the value of the connectionCount record component
    • memoryUsed

      public long memoryUsed()
      Returns the value of the memoryUsed record component.
      Returns:
      the value of the memoryUsed record component
    • keyCount

      public long keyCount()
      Returns the value of the keyCount record component.
      Returns:
      the value of the keyCount record component
    • avgLatency

      public Duration avgLatency()
      Returns the value of the avgLatency record component.
      Returns:
      the value of the avgLatency record component
    • p99Latency

      public Duration p99Latency()
      Returns the value of the p99Latency record component.
      Returns:
      the value of the p99Latency record component
    • lastResetTime

      public Instant lastResetTime()
      Returns the value of the lastResetTime record component.
      Returns:
      the value of the lastResetTime record component