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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for DistributedCacheStats. -
Constructor Summary
ConstructorsConstructorDescriptionDistributedCacheStats(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 aDistributedCacheStatsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionGets the average load time.Returns the value of theavgLatencyrecord component.builder()Creates a builder for DistributedCacheStats.intReturns the value of theconnectionCountrecord component.static DistributedCacheStatsempty()Creates an empty stats instance.final booleanIndicates whether some other object is "equal to" this one.longReturns the value of theevictionCountrecord component.final inthashCode()Returns a hash code value for this object.longhitCount()Returns the value of thehitCountrecord component.doublehitRate()Gets the hit rate.longkeyCount()Returns the value of thekeyCountrecord component.Returns the value of thelastResetTimerecord component.longReturns the value of theloadCountrecord component.longReturns the value of theloadFailureCountrecord component.longReturns the value of theloadSuccessCountrecord component.doubleGets the load success rate.longReturns the value of thememoryUsedrecord component.longReturns the value of themissCountrecord component.doublemissRate()Gets the miss rate.Returns the value of thep99Latencyrecord component.longReturns the value of therequestCountrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetotalLoadTimerecord component.
-
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 aDistributedCacheStatsrecord class.- Parameters:
hitCount- the value for thehitCountrecord componentmissCount- the value for themissCountrecord componentloadCount- the value for theloadCountrecord componentloadSuccessCount- the value for theloadSuccessCountrecord componentloadFailureCount- the value for theloadFailureCountrecord componenttotalLoadTime- the value for thetotalLoadTimerecord componentevictionCount- the value for theevictionCountrecord componentrequestCount- the value for therequestCountrecord componentconnectionCount- the value for theconnectionCountrecord componentmemoryUsed- the value for thememoryUsedrecord componentkeyCount- the value for thekeyCountrecord componentavgLatency- the value for theavgLatencyrecord componentp99Latency- the value for thep99Latencyrecord componentlastResetTime- the value for thelastResetTimerecord component
-
-
Method Details
-
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
Gets the average load time. 获取平均加载时间。- Returns:
- the average load time - 平均加载时间
-
builder
Creates a builder for DistributedCacheStats. 创建 DistributedCacheStats 构建器。- Returns:
- the builder - 构建器
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
hitCount
-
missCount
-
loadCount
-
loadSuccessCount
public long loadSuccessCount()Returns the value of theloadSuccessCountrecord component.- Returns:
- the value of the
loadSuccessCountrecord component
-
loadFailureCount
public long loadFailureCount()Returns the value of theloadFailureCountrecord component.- Returns:
- the value of the
loadFailureCountrecord component
-
totalLoadTime
Returns the value of thetotalLoadTimerecord component.- Returns:
- the value of the
totalLoadTimerecord component
-
evictionCount
public long evictionCount()Returns the value of theevictionCountrecord component.- Returns:
- the value of the
evictionCountrecord component
-
requestCount
public long requestCount()Returns the value of therequestCountrecord component.- Returns:
- the value of the
requestCountrecord component
-
connectionCount
public int connectionCount()Returns the value of theconnectionCountrecord component.- Returns:
- the value of the
connectionCountrecord component
-
memoryUsed
public long memoryUsed()Returns the value of thememoryUsedrecord component.- Returns:
- the value of the
memoryUsedrecord component
-
keyCount
-
avgLatency
Returns the value of theavgLatencyrecord component.- Returns:
- the value of the
avgLatencyrecord component
-
p99Latency
Returns the value of thep99Latencyrecord component.- Returns:
- the value of the
p99Latencyrecord component
-
lastResetTime
Returns the value of thelastResetTimerecord component.- Returns:
- the value of the
lastResetTimerecord component
-