本文整理汇总了Java中com.github.benmanes.caffeine.cache.stats.CacheStats类的典型用法代码示例。如果您正苦于以下问题:Java CacheStats类的具体用法?Java CacheStats怎么用?Java CacheStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheStats类属于com.github.benmanes.caffeine.cache.stats包,在下文中一共展示了CacheStats类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCache
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
public Map<String, Object> getCache() {
CacheStats stats = versionCache.getStats();
Map<String, Object> cache = new TreeMap<>();
cache.put("averageLoadPenalty", stats.averageLoadPenalty());
cache.put("evictionCount", stats.evictionCount());
cache.put("hitCount", stats.hitCount());
cache.put("hitRate", stats.hitRate());
cache.put("loadCount", stats.loadCount());
cache.put("loadFailureCount", stats.loadFailureCount());
cache.put("loadFailureRate", stats.loadFailureRate());
cache.put("loadSuccessCount", stats.loadSuccessCount());
cache.put("missCount", stats.missCount());
cache.put("missRate", stats.missRate());
cache.put("requestCount", stats.requestCount());
cache.put("totalLoadTime", stats.totalLoadTime());
cache.put("estimatedSize", versionCache.estimatedSize());
return cache;
}
示例2: serialize
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public void serialize(CacheStats value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeStartObject();
gen.writeNumberField("requestCount", value.requestCount());
gen.writeNumberField("hitCount", value.hitCount());
gen.writeNumberField("hitRate", value.hitRate());
gen.writeNumberField("missCount", value.missCount());
gen.writeNumberField("missRate", value.missRate());
gen.writeNumberField("loadCount", value.loadCount());
gen.writeNumberField("loadSuccessCount", value.loadSuccessCount());
gen.writeNumberField("loadFailureCount", value.loadFailureCount());
gen.writeNumberField("loadFailureRate", value.loadFailureRate());
gen.writeNumberField("totalLoadTime", value.totalLoadTime());
gen.writeNumberField("averageLoadPenalty", value.averageLoadPenalty());
gen.writeNumberField("evictionCount", value.evictionCount());
gen.writeNumberField("evictionWeight", value.evictionWeight());
gen.writeEndObject();
}
示例3: getCacheStatistics
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager,
CaffeineCache cache) {
DefaultCacheStatistics statistics = new DefaultCacheStatistics();
statistics.setSize(cache.getNativeCache().estimatedSize());
CacheStats caffeineStatistics = cache.getNativeCache().stats();
if (caffeineStatistics.requestCount() > 0) {
statistics.setHitRatio(caffeineStatistics.hitRate());
statistics.setMissRatio(caffeineStatistics.missRate());
}
return statistics;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:CaffeineCacheStatisticsProvider.java
示例4: cacheStats
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
/**
* Returns the cache stats of the server.
*/
public Optional<CacheStats> cacheStats() {
// FIXME(trustin): Remove this from the public API.
final ProjectManager pm = this.pm;
if (pm == null) {
return Optional.empty();
}
return Optional.of(pm.cacheStats());
}
示例5: getFile
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Test
public void getFile() {
final String project = testName.getMethodName();
final CentralDogma client = rule.client();
client.createProject(project).join();
final CacheStats stats1 = cacheStatsSupplier.get();
final Commit commit = client.push(project, REPO_MAIN, HEAD, SYSTEM, "Add a file",
Change.ofTextUpsert("/foo.txt", "bar")).join();
// NB: A push operation involves a history() operation to retrieve the last commit.
// Therefore we should observe one cache miss.
final CacheStats stats2 = cacheStatsSupplier.get();
assertThat(stats2.missCount()).isEqualTo(stats1.missCount() + 1);
// First getFile() should miss.
final Query<Object> query = Query.identity("/foo.txt");
final Entry<?> entry = client.getFile(project, REPO_MAIN, HEAD, query).join();
final CacheStats stats3 = cacheStatsSupplier.get();
assertThat(stats3.missCount()).isEqualTo(stats2.missCount() + 1);
// Subsequent getFile() should never miss.
for (int i = 0; i < 3; i++) {
final CacheStats stats4 = cacheStatsSupplier.get();
// Use the relative revision as well as the absolute revision.
final Entry<?> cachedEntry1 = client.getFile(project, REPO_MAIN, commit.revision(), query).join();
final Entry<?> cachedEntry2 = client.getFile(project, REPO_MAIN, HEAD, query).join();
// They should return the same result.
assertThat(cachedEntry1).isEqualTo(entry);
assertThat(cachedEntry1).isEqualTo(cachedEntry2);
// .. and should hit the cache.
final CacheStats stats5 = cacheStatsSupplier.get();
assertThat(stats5.hitCount()).isEqualTo(stats4.hitCount() + 2);
assertThat(stats5.missCount()).isEqualTo(stats4.missCount());
}
}
示例6: history
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Test
public void history() throws Exception {
final String project = testName.getMethodName();
final CentralDogma client = rule.client();
client.createProject(project).join();
final Commit commit1 = client.push(project, REPO_MAIN, HEAD, SYSTEM, "Add a file",
Change.ofTextUpsert("/foo.txt", "bar")).join();
final CacheStats stats1 = cacheStatsSupplier.get();
// Get the history in various combination of from/to revisions.
final List<CommitAndChanges<?>> history1 =
client.getHistory(project, REPO_MAIN, HEAD, new Revision(-3), "/**").join();
final List<CommitAndChanges<?>> history2 =
client.getHistory(project, REPO_MAIN, HEAD, INIT, "/**").join();
final List<CommitAndChanges<?>> history3 =
client.getHistory(project, REPO_MAIN, commit1.revision(), new Revision(-3), "/**").join();
final List<CommitAndChanges<?>> history4 =
client.getHistory(project, REPO_MAIN, commit1.revision(), INIT, "/**").join();
// and they should all same.
assertThat(history1).isEqualTo(history2);
assertThat(history1).isEqualTo(history3);
assertThat(history1).isEqualTo(history4);
final CacheStats stats2 = cacheStatsSupplier.get();
// Should miss once and hit 3 times.
assertThat(stats2.missCount()).isEqualTo(stats1.missCount() + 1);
assertThat(stats2.hitCount()).isEqualTo(stats1.hitCount() + 3);
}
示例7: getDiffs
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Test
public void getDiffs() throws Exception {
final String project = testName.getMethodName();
final CentralDogma client = rule.client();
client.createProject(project).join();
final Commit commit1 = client.push(project, REPO_MAIN, HEAD, SYSTEM, "Add a file",
Change.ofTextUpsert("/foo.txt", "bar")).join();
final CacheStats stats1 = cacheStatsSupplier.get();
// Get the diffs in various combination of from/to revisions.
final List<Change<?>> diff1 =
client.getDiffs(project, REPO_MAIN, HEAD, new Revision(-3), "/**").join();
final List<Change<?>> diff2 =
client.getDiffs(project, REPO_MAIN, HEAD, INIT, "/**").join();
final List<Change<?>> diff3 =
client.getDiffs(project, REPO_MAIN, commit1.revision(), new Revision(-3), "/**").join();
final List<Change<?>> diff4 =
client.getDiffs(project, REPO_MAIN, commit1.revision(), INIT, "/**").join();
// and they should all same.
assertThat(diff1).isEqualTo(diff2);
assertThat(diff1).isEqualTo(diff3);
assertThat(diff1).isEqualTo(diff4);
final CacheStats stats2 = cacheStatsSupplier.get();
// Should miss once and hit 3 times.
assertThat(stats2.missCount()).isEqualTo(stats1.missCount() + 1);
assertThat(stats2.hitCount()).isEqualTo(stats1.hitCount() + 3);
}
示例8: doHealthCheck
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
CacheStats stats = this.cache.stats();
builder.up().withDetail("evictionCount", stats.evictionCount());
builder.up().withDetail("hitRate", stats.hitRate());
builder.up().withDetail("missRate", stats.missRate());
builder.up().withDetail("hitCount", stats.hitCount());
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow-metrics-collector,代码行数:9,代码来源:CaffeineHealthIndicator.java
示例9: func
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
private ToDoubleFunction<CaffeineMetrics> func(@Nullable Type type,
ToDoubleFunction<CacheReference> valueFunction) {
return value -> {
double sum = 0;
synchronized (cacheRefs) {
for (Iterator<CacheReference> i = cacheRefs.iterator(); i.hasNext();) {
final CacheReference ref = i.next();
final boolean garbageCollected = ref.updateCacheStats();
if (!garbageCollected) {
sum += valueFunction.applyAsDouble(ref);
} else {
// Remove the garbage-collected reference from the list to prevent it from
// growing infinitely.
i.remove();
// Accumulate the stats of the removed reference so the counters do not decrease.
// NB: We do not accumulate 'estimatedSize' because it's not a counter but a gauge.
final CacheStats stats = ref.cacheStats;
statsForGarbageCollected[HIT_COUNT.ordinal()] += stats.hitCount();
statsForGarbageCollected[MISS_COUNT.ordinal()] += stats.missCount();
statsForGarbageCollected[EVICTION_COUNT.ordinal()] += stats.evictionCount();
statsForGarbageCollected[EVICTION_WEIGHT.ordinal()] += stats.evictionWeight();
statsForGarbageCollected[LOAD_SUCCESS_COUNT.ordinal()] += stats.loadSuccessCount();
statsForGarbageCollected[LOAD_FAILURE_COUNT.ordinal()] += stats.loadFailureCount();
statsForGarbageCollected[TOTAL_LOAD_TIME.ordinal()] += stats.totalLoadTime();
}
}
if (type != null) {
// Add the value of the garbage-collected caches.
sum += statsForGarbageCollected[type.ordinal()];
}
}
return sum;
};
}
示例10: CacheStatsSerializer
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
CacheStatsSerializer() {
super(CacheStats.class);
}
示例11: cacheStats
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public CacheStats cacheStats() {
return cache != null ? cache.stats() : CacheStats.empty();
}
示例12: cacheStats
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public CacheStats cacheStats() {
return delegate().cacheStats();
}
示例13: stats
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
public CacheStats stats() {
return cache.synchronous().stats();
}
示例14: getStats
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
public CacheStats getStats() {
return versions.stats();
}
示例15: update
import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
void update(long hitCount, long missCount, long loadSuccessCount, long loadFailureCount,
long totalLoadTime, long evictionCount, long evictionWeight, long estimatedSize) {
stats = new CacheStats(hitCount, missCount, loadSuccessCount, loadFailureCount,
totalLoadTime, evictionCount, evictionWeight);
this.estimatedSize = estimatedSize;
}