DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Cache stats always zero #1534

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
i 'm building a cache using LoadingCache 

 dataCache = CacheBuilder.newBuilder().expireAfterWrite(600,       TimeUnit.MINUTES)
                .maximumSize(SystemInfoLocal.CACHE_SIZE)
                .build(new CacheLoader<String, String[]>() {
                    @Override
                    public String[] load(String queryKey) throws Exception {
                        return getDataByKey(queryKey);
                    }
                });

but when I try to get CacheStat object ( by call toString method ) 

dataCache.stats().toString();

always retrieved this:

CacheStats{hitCount=0, missCount=0, 
loadSuccessCount=0,loadExceptionCount=0,totalLoadTime=0, evictionCount=0}

Original issue reported on code.google.com by tunguyen...@admicro.vn on 16 Sep 2013 at 10:22

GoogleCodeExporter commented 9 years ago
This is because you did not call #recordStats() on the CacheBuilder. By default 
gathering of statistics is disabled. (In which case the EMPTY_STATS object is 
returned.)

Original comment by stephan...@gmail.com on 16 Sep 2013 at 11:15

GoogleCodeExporter commented 9 years ago
thanks for your helping , it's working :D 

Original comment by tunguyen...@admicro.vn on 16 Sep 2013 at 11:23

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 16 Sep 2013 at 11:24

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08