Module bus.cache

Class ZookeeperMetrics

java.lang.Object
org.miaixz.bus.cache.support.metrics.ZookeeperMetrics
All Implemented Interfaces:
Metrics

public class ZookeeperMetrics extends Object implements Metrics
ZooKeeper缓存命中率统计实现

基于ZooKeeper实现的分布式缓存命中率统计,使用Curator框架操作ZooKeeper, 支持分布式原子计数器,适用于分布式环境下的缓存命中率统计。

Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • ZookeeperMetrics

      public ZookeeperMetrics(String zkServer)
      构造方法
      Parameters:
      zkServer - ZooKeeper服务器地址
    • ZookeeperMetrics

      public ZookeeperMetrics(String zkServer, String productName)
      构造方法
      Parameters:
      zkServer - ZooKeeper服务器地址
      productName - 产品名称,用于命名空间隔离
  • Method Details

    • hitIncr

      public void hitIncr(String pattern, int count)
      增加命中次数
      Specified by:
      hitIncr in interface Metrics
      Parameters:
      pattern - 缓存模式/分组名称
      count - 增加的命中数量
    • reqIncr

      public void reqIncr(String pattern, int count)
      增加请求次数
      Specified by:
      reqIncr in interface Metrics
      Parameters:
      pattern - 缓存模式/分组名称
      count - 增加的请求数量
    • getHitting

      public Map<String,Metrics.Snapshot> getHitting()
      获取缓存命中率统计信息
      Specified by:
      getHitting in interface Metrics
      Returns:
      缓存命中率统计映射,键为缓存模式/分组名称,值为HittingDO对象
    • reset

      public void reset(String pattern)
      重置指定缓存模式的命中率统计
      Specified by:
      reset in interface Metrics
      Parameters:
      pattern - 缓存模式/分组名称
    • resetAll

      public void resetAll()
      重置所有缓存模式的命中率统计
      Specified by:
      resetAll in interface Metrics
    • tearDown

      @PreDestroy public void tearDown()
      销毁方法

      使用@PreDestroy注解,在Bean销毁时等待队列处理完毕并关闭执行器