Cache stats - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Cache stats method.

This code example shows how to use the following methods:cleanUp, size, stats
    protected abstract Cache<?, ?> getCache();
 
    private CacheStats getCachedCacheStats() {
        if (cache == null || nextLoad <= System.currentTimeMillis()) {
            cache = getCache();
            cacheStats = cache.stats();
            size = cache.size();
            nextLoad = System.currentTimeMillis() + loadIterval;
        } 
         
        return cacheStats;
    } 
 
    public final long getLoadIterval() { 
        return loadIterval;
    } 
 
    /** 
     * Number of milliseconds between calls to {@link CharacterDataEventImpl#getEventCacheStats()} 
     */ 

7
CodeRank
This code example shows how to use the following methods:size, stats
		this.cache = cache;
	} 
 
	@Override 
	public void addMetrics(MetricTreeObject tree) {
		long size = cache.size();
		CacheStats stats = cache.stats();
 
		MetricTreeObject subtree = tree.getSubtree(key);
 
		subtree.addInt("size", size);
		subtree.addInt("evictionCount", stats.evictionCount());
		subtree.addInt("hitCount", stats.hitCount());
		subtree.addInt("loadCount", stats.loadCount());
		subtree.addInt("loadExceptionCount", stats.loadExceptionCount());
		subtree.addInt("loadSuccessCount", stats.loadSuccessCount());
		subtree.addInt("missCount", stats.missCount());
		subtree.addInt("requestCount", stats.requestCount());
		subtree.addInt("totalLoadTime", stats.totalLoadTime());
 
6
CodeRank
This code example shows how to use the following methods:stats
		return cache.asMap().keySet(); 
	} 
 
	@Override 
	public long getCacheHits() { 
		return cache.stats().hitCount(); 
	} 
 
	@Override 
	public long getCacheMisses() { 
		return cache.stats().missCount(); 
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:snapshot
This code example shows how to use the following methods:stats
     * Returns a set of statistics about the cache contents and usage. 
     * 
     * @return a set of statistics about the cache contents and usage 
     */ 
    public CacheStats stats() {
        return cache.stats();
    } 
 
    /** 
     * Exception thrown by {@link CacheLoader#load(Object)} when the authenticator returns {@link Optional#empty()}. 
     * This is used to prevent caching of invalid credentials. 
     */ 
    private static class InvalidCredentialsException extends Exception {
    } 
} 
4
CodeRank
This code example shows how to use the following methods:stats
    public String getName() {
        return name;
    } 
 
    private com.google.common.cache.CacheStats stats() {
        return cache.stats().minus(lastSnapshot);
    } 
 
    static String timeInWords(long nanos) {
        long millis = TimeUnit.NANOSECONDS.toMillis(nanos);
        return String.format("%d min, %d sec",
                TimeUnit.MILLISECONDS.toMinutes(millis),
                TimeUnit.MILLISECONDS.toSeconds(millis) -
                        TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))
        ); 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:stats
		cache.invalidateAll();
	} 
 
	@Override 
    public long getRequestCount() { 
        return cache.stats().requestCount();
    } 
  
    @Override 
    public long getHitCount() { 
        return cache.stats().hitCount();
    } 
  
    @Override 
    public double getHitRate() { 
        return cache.stats().hitRate();
    } 
  
    @Override 
    public long getMissCount() { 
4
CodeRank
stats Method Overview
Returns a current snapshot of this cache's cumulative statistics.
See Code Examples for other Guava Cache Methods: