Class CacheAccessTracker<K,​V>

  • All Implemented Interfaces:
    Cache<K,​V>

    public class CacheAccessTracker<K,​V>
    extends java.lang.Object
    implements Cache<K,​V>
    Cache wrapper exposing the number of read accesses and the number of misses ot the underlying cache via the StatisticsProvider.
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheAccessTracker​(@NotNull java.lang.String name, @NotNull StatisticsProvider statisticsProvider, @NotNull Cache<K,​V> delegate)
      Create a new wrapper exposing the access statistics under the given name to the passed statisticsProvider.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V get​(K key)  
      void put​(K key, V value)
      Add a mapping from key to value.
      void put​(K key, V value, byte cost)
      Add a mapping from key to value with a given cost.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CacheAccessTracker

        public CacheAccessTracker​(@NotNull
                                  @NotNull java.lang.String name,
                                  @NotNull
                                  @NotNull StatisticsProvider statisticsProvider,
                                  @NotNull
                                  @NotNull Cache<K,​V> delegate)
        Create a new wrapper exposing the access statistics under the given name to the passed statisticsProvider.
        Parameters:
        name - name under which to expose the access statistics
        statisticsProvider - statistics provider where the access statistics is recorded to
        delegate - the underlying, wrapped cache.
    • Method Detail

      • put

        public void put​(@NotNull
                        K key,
                        @NotNull
                        V value)
        Description copied from interface: Cache
        Add a mapping from key to value.
        Specified by:
        put in interface Cache<K,​V>
      • put

        public void put​(@NotNull
                        K key,
                        @NotNull
                        V value,
                        byte cost)
        Description copied from interface: Cache
        Add a mapping from key to value with a given cost.
        Specified by:
        put in interface Cache<K,​V>
      • get

        @Nullable
        public V get​(@NotNull
                     K key)
        Specified by:
        get in interface Cache<K,​V>
        Returns:
        The mapping for key, or null if none.