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 modules cache2k-jmx and cache2k-micrometer are available.

    Statistics are retrieved with minimum effect on the running application and avoid locks. This may lead to slight inconsistencies within the metrics, e.g. the two values getTotalLoadMillis() and getLoadCount() are not updated atomically.

    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.
      • 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()
        Refreshed entries counter.
      • getRefreshFailedCount

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

        long getRefreshedHitCount()
        How many times there was 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:
      • 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 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.