• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CacheStats类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.benmanes.caffeine.cache.stats.CacheStats的典型用法代码示例。如果您正苦于以下问题:Java CacheStats类的具体用法?Java CacheStats怎么用?Java CacheStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CacheStats类属于com.github.benmanes.caffeine.cache.stats包,在下文中一共展示了CacheStats类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:valery1707,项目名称:javadoc-badge,代码行数:19,代码来源:StatusRepository.java


示例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();
}
 
开发者ID:line,项目名称:centraldogma,代码行数:19,代码来源:CacheStatsSerializer.java


示例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());
}
 
开发者ID:line,项目名称:centraldogma,代码行数:13,代码来源:CentralDogma.java


示例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());
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:40,代码来源:CacheTest.java


示例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);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:33,代码来源:CacheTest.java


示例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);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:33,代码来源:CacheTest.java


示例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;
    };
}
 
开发者ID:line,项目名称:armeria,代码行数:38,代码来源:CaffeineMetricSupport.java


示例10: CacheStatsSerializer

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
CacheStatsSerializer() {
    super(CacheStats.class);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:4,代码来源:CacheStatsSerializer.java


示例11: cacheStats

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public CacheStats cacheStats() {
    return cache != null ? cache.stats() : CacheStats.empty();
}
 
开发者ID:line,项目名称:centraldogma,代码行数:5,代码来源:DefaultProjectManager.java


示例12: cacheStats

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public CacheStats cacheStats() {
    return delegate().cacheStats();
}
 
开发者ID:line,项目名称:centraldogma,代码行数:5,代码来源:SafeProjectManager.java


示例13: stats

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
public CacheStats stats() {
    return cache.synchronous().stats();
}
 
开发者ID:line,项目名称:centraldogma,代码行数:4,代码来源:RepositoryCache.java


示例14: getStats

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
public CacheStats getStats() {
	return versions.stats();
}
 
开发者ID:valery1707,项目名称:javadoc-badge,代码行数:4,代码来源:VersionCache.java


示例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;
}
 
开发者ID:line,项目名称:armeria,代码行数:7,代码来源:CaffeineMetricSupportTest.java


示例16: stats

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Nonnull
@Override
public CacheStats stats() {
    statsCalls++;
    return stats;
}
 
开发者ID:line,项目名称:armeria,代码行数:7,代码来源:CaffeineMetricSupportTest.java


示例17: collect

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();
    List<String> labelNames = Arrays.asList("cache");

    CounterMetricFamily cacheHitTotal = new CounterMetricFamily("caffeine_cache_hit_total",
            "Cache hit totals", labelNames);
    mfs.add(cacheHitTotal);

    CounterMetricFamily cacheMissTotal = new CounterMetricFamily("caffeine_cache_miss_total",
            "Cache miss totals", labelNames);
    mfs.add(cacheMissTotal);

    CounterMetricFamily cacheRequestsTotal = new CounterMetricFamily("caffeine_cache_requests_total",
            "Cache request totals, hits + misses", labelNames);
    mfs.add(cacheRequestsTotal);

    CounterMetricFamily cacheEvictionTotal = new CounterMetricFamily("caffeine_cache_eviction_total",
            "Cache eviction totals, doesn't include manually removed entries", labelNames);
    mfs.add(cacheEvictionTotal);

    GaugeMetricFamily cacheEvictionWeight = new GaugeMetricFamily("caffeine_cache_eviction_weight",
            "Cache eviction weight", labelNames);
    mfs.add(cacheEvictionWeight);

    CounterMetricFamily cacheLoadFailure = new CounterMetricFamily("caffeine_cache_load_failure_total",
            "Cache load failures", labelNames);
    mfs.add(cacheLoadFailure);

    CounterMetricFamily cacheLoadTotal = new CounterMetricFamily("caffeine_cache_loads_total",
            "Cache loads: both success and failures", labelNames);
    mfs.add(cacheLoadTotal);

    GaugeMetricFamily cacheSize = new GaugeMetricFamily("caffeine_cache_estimated_size",
            "Estimated cache size", labelNames);
    mfs.add(cacheSize);

    SummaryMetricFamily cacheLoadSummary = new SummaryMetricFamily("caffeine_cache_load_duration_seconds",
            "Cache load duration: both success and failures", labelNames);
    mfs.add(cacheLoadSummary);

    for(Map.Entry<String, Cache> c: children.entrySet()) {
        List<String> cacheName = Arrays.asList(c.getKey());
        CacheStats stats = c.getValue().stats();

        try{
            cacheEvictionWeight.addMetric(cacheName, stats.evictionWeight());
        } catch (Exception e) {
            // EvictionWeight metric is unavailable, newer version of Caffeine is needed.
        }

        cacheHitTotal.addMetric(cacheName, stats.hitCount());
        cacheMissTotal.addMetric(cacheName, stats.missCount());
        cacheRequestsTotal.addMetric(cacheName, stats.requestCount());
        cacheEvictionTotal.addMetric(cacheName, stats.evictionCount());
        cacheSize.addMetric(cacheName, c.getValue().estimatedSize());

        if(c.getValue() instanceof LoadingCache) {
            cacheLoadFailure.addMetric(cacheName, stats.loadFailureCount());
            cacheLoadTotal.addMetric(cacheName, stats.loadCount());

            cacheLoadSummary.addMetric(cacheName, stats.loadCount(), stats.totalLoadTime() / Collector.NANOSECONDS_PER_SECOND);
        }
    }
    return mfs;
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:67,代码来源:CacheMetricsCollector.java


示例18: snapshot

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
@Override
public CacheStats snapshot() {
    return new CacheStats(hitCount.getCount(), missCount.getCount(), loadSuccessCount.getCount(), loadFailureCount.getCount(), totalLoadTime.getCount(),
                          evictionCount.getCount(), evictionWeight.getCount());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:6,代码来源:MetricsStatsCounter.java


示例19: cacheStats

import com.github.benmanes.caffeine.cache.stats.CacheStats; //导入依赖的package包/类
CacheStats cacheStats(); 
开发者ID:line,项目名称:centraldogma,代码行数:2,代码来源:ProjectManager.java



注:本文中的com.github.benmanes.caffeine.cache.stats.CacheStats类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HexColor类代码示例发布时间:2022-05-22
下一篇:
Java GetQueueUserAclsInfoResponseProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap