Interface CacheStatistics


  • public interface CacheStatistics
    Set of metrics for cache statistics. The cache statistics can be retrieved via CacheControl.sampleStatistics(). The statistics may be unavailable if disabled via Cache2kBuilder.disableStatistics(boolean). General information about the cache is available via CacheInfo.

    For exporting to a monitoring system the separate modes cache2k-jmx and cache2k-micrometer are available.

    Author:
    Jens Wilke
    • Method Detail

      • getInsertCount

        long getInsertCount()
        How many times a new entry was inserted into the cache.
      • getGetCount

        long getGetCount()
        How often data was requested from the cache. In multi threading scenarios this counter may be not totally accurate. For performance reason the cache implementation may choose to only present a best effort value. It is guaranteed that the usage count is always greater than the miss count.
      • getMissCount

        long getMissCount()
        Counter of the event that: a client requested a data which was not present in the cache or had expired. In other word containsKey does not count a miss.
      • getLoadCount

        long getLoadCount()
        How many times a load succeeded.
      • getLoadExceptionCount

        long getLoadExceptionCount()
        Number of exceptions thrown by the CacheLoader.
      • getSuppressedLoadExceptionCount

        long getSuppressedLoadExceptionCount()
        Number of exceptions thrown by the CacheLoader that were ignored and the previous data value got returned.
      • getMillisPerLoad

        double getMillisPerLoad()
        Average number of milliseconds per load.
      • getTotalLoadMillis

        long getTotalLoadMillis()
        Total number of time spent loading entries from the cache loader.
      • getRefreshCount

        long getRefreshCount()
        A value of an a cache entry was refreshed.
      • getRefreshFailedCount

        long getRefreshFailedCount()
        Counter how many times a refresh failed, because there were not enough thread resources available.
      • getRefreshedHitCount

        long getRefreshedHitCount()
        How many times we had a hit on a refreshed entry. This counter is incremented once, after a refreshed entry is requested by the application for the first time. That means the quotient from refreshedCount and refreshedHitCount is the efficiency of refreshing.
      • getExpiredCount

        long getExpiredCount()
        A cache entry has expired. The counter is incremented after the actual expiry.

        This can mean that the cache entry is removed or just marked as expired in case that the keep value option is enabled.

        See Also:
        Cache2kConfig.setKeepDataAfterExpired(boolean)
      • getEvictedCount

        long getEvictedCount()
        An entry was evicted from the cache because of size limits.
      • getEvictedOrRemovedWeight

        long getEvictedOrRemovedWeight()
        Accumulated number of weight evicted or removed entries
      • getPutCount

        long getPutCount()
        The total number of insert or update operations.
      • getRemoveCount

        long getRemoveCount()
        Number of remove operations.
      • getClearedCount

        long getClearedCount()
        Number entries removed from the cache by the Cache.clear() operation.
      • getClearCallsCount

        long getClearCallsCount()
        Number of Cache.clear() invocations.
      • getKeyMutationCount

        long getKeyMutationCount()
        Number of key mutations occurred. This should be always 0, otherwise it is an indicator that the a key object was modified after it was stored in the cache. Whenever `keyMutationCount` is non-zero, check and correct your application.

        How it works: When an entry is evicted the cache checks whether the hashCode of the key object is identical to the code when it was inserted. If not, the counter is incremented. When a mutation is detected, also a warning is logged but only once during the cache lifetime.

      • getHitRate

        double getHitRate()
        The percentage of cache accesses the cache delivered data.