spring-data-redis CacheStatistics 源码

  • 2022-08-16
  • 浏览 (373)

spring-data-redis CacheStatistics 代码

文件路径:/src/main/java/org/springframework/data/redis/cache/CacheStatistics.java

/*
 * Copyright 2020-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.data.redis.cache;

import java.time.Instant;
import java.util.concurrent.TimeUnit;

/**
 * Cache statistics for a {@link RedisCache}. <br />
 * <strong>NOTE:</strong> {@link CacheStatistics} only serve local (in memory) data and do not collect any server
 * statistics.
 *
 * @author Mark Paluch
 * @author Christoph Strobl
 * @since 2.4
 */
public interface CacheStatistics {

	/**
	 * @return the name of the {@link RedisCache}.
	 */
	String getCacheName();

	/**
	 * @return number of put operations on the cache.
	 */
	long getPuts();

	/**
	 * @return the total number of get operations including both {@link #getHits() hits} and {@link #getMisses() misses}.
	 */
	long getGets();

	/**
	 * @return the number of cache get hits.
	 */
	long getHits();

	/**
	 * @return number of cache get misses.
	 */
	long getMisses();

	/**
	 * @return the number of {@link #getGets() gets} that have not yet been answered (neither {@link #getHits() hit} nor
	 *         {@link #getMisses() miss}).
	 */
	default long getPending() {
		return getGets() - (getHits() + getMisses());
	}

	/**
	 * @return number of cache removals.
	 */
	long getDeletes();

	/**
	 * @param unit the time unit to report the lock wait duration.
	 * @return lock duration using the given {@link TimeUnit} if the cache is configured to use locking.
	 */
	long getLockWaitDuration(TimeUnit unit);

	/**
	 * @return initial point in time when started statistics capturing.
	 */
	Instant getSince();

	/**
	 * @return instantaneous point in time of last statistics counter reset. Equals {@link #getSince()} if never reset.
	 */
	Instant getLastReset();

	/**
	 * @return the statistics time.
	 */
	default Instant getTime() {
		return Instant.now();
	}
}

相关信息

spring-data-redis 源码目录

相关文章

spring-data-redis BatchStrategies 源码

spring-data-redis BatchStrategy 源码

spring-data-redis CacheKeyPrefix 源码

spring-data-redis CacheStatisticsCollector 源码

spring-data-redis CacheStatisticsProvider 源码

spring-data-redis DefaultCacheStatisticsCollector 源码

spring-data-redis DefaultRedisCacheWriter 源码

spring-data-redis MutableCacheStatistics 源码

spring-data-redis NoOpCacheStatisticsCollector 源码

spring-data-redis RedisCache 源码

0  赞