java.lang.Object
org.miaixz.bus.cache.support.metrics.AbstractMetrics
org.miaixz.bus.cache.support.metrics.PostgreSQLMetrics
- All Implemented Interfaces:
Metrics
PostgreSQL数据库缓存命中率统计实现
基于PostgreSQL数据库实现的缓存命中率统计,使用HikariCP连接池和JdbcTemplate进行数据库操作。 自动创建缓存统计表,支持并发更新和乐观锁机制。
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested classes/interfaces inherited from class org.miaixz.bus.cache.support.metrics.AbstractMetrics
AbstractMetrics.DataDONested classes/interfaces inherited from interface org.miaixz.bus.cache.Metrics
Metrics.Snapshot -
Constructor Summary
ConstructorsConstructorDescriptionPostgreSQLMetrics(String url, String username, String password) 构造方法PostgreSQLMetrics(Map<String, Object> context) 构造方法 -
Method Summary
Modifier and TypeMethodDescriptionprotected Supplier<org.springframework.jdbc.core.JdbcOperations> jdbcOperationsSupplier(Map<String, Object> context) 创建JdbcOperations并初始化数据库protected Stream<AbstractMetrics.DataDO> transferResults(List<Map<String, Object>> mapResults) 将数据库查询结果转换为DataDO流Methods inherited from class org.miaixz.bus.cache.support.metrics.AbstractMetrics
getHitting, hitIncr, newHashMap, reqIncr, reset, resetAll, tearDownMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.cache.Metrics
summaryName
-
Constructor Details
-
PostgreSQLMetrics
构造方法- Parameters:
context- 上下文参数
-
PostgreSQLMetrics
构造方法- Parameters:
url- 数据库URLusername- 用户名password- 密码
-
-
Method Details
-
jdbcOperationsSupplier
protected Supplier<org.springframework.jdbc.core.JdbcOperations> jdbcOperationsSupplier(Map<String, Object> context) 创建JdbcOperations并初始化数据库创建PostgreSQL数据库连接池,初始化JdbcTemplate,并创建缓存统计表
- Specified by:
jdbcOperationsSupplierin classAbstractMetrics- Parameters:
context- 上下文参数- Returns:
- 初始化完成的JdbcOperations对象
-
transferResults
将数据库查询结果转换为DataDO流将查询结果Map转换为DataDO对象流,便于后续处理
- Specified by:
transferResultsin classAbstractMetrics- Parameters:
mapResults- 数据库查询结果- Returns:
- DataDO流
-