Interface CachingTier<K,​V>

  • Type Parameters:
    K -
    V -
    All Known Implementing Classes:
    OnHeapCachingTier

    public interface CachingTier<K,​V>
    This interface is to be implemented by CachingTier that sit above the AuthoritativeTier. An important contract here is that a value being faulted in get is to be entirely faulted in before it can become an eviction candidate, i.e. this cache can never evict mappings being faulted in
    Author:
    Alex Snaps
    • Method Detail

      • loadOnPut

        boolean loadOnPut()
        Returns true if values should be loaded to this cache on put.

        This may be a dynamic decision, based for example on the occupancy of the cache.

        Returns:
        true if values should be loaded on put
      • get

        V get​(K key,
              java.util.concurrent.Callable<V> source,
              boolean updateStats)
        Returns the value associated with the key, or populates the mapping using the Callable instance
        Parameters:
        key - the key to look up
        source - the source to use, in the case of no mapping present
        updateStats - true to update the stats, false otherwise
        Returns:
        the value mapped to the key
      • remove

        V remove​(K key)
        Removes the mapping associated to the key passed in
        Parameters:
        key - the key to the mapping to remove
        Returns:
        the value removed, null if none
      • clear

        void clear()
        Clears the cache... Doesn't notify any listeners
      • clearAndNotify

        void clearAndNotify()
        Clears the cache notifying listeners
      • getInMemorySize

        @Deprecated
        int getInMemorySize()
        Deprecated.
        Can we avoid having this somehow ?
        Returns:
        the count of entries held in heap
      • getOffHeapSize

        @Deprecated
        int getOffHeapSize()
        Deprecated.
        Can we avoid having this somehow ?
        Returns:
        the count of entries held off heap
      • contains

        @Deprecated
        boolean contains​(K key)
        Deprecated.
        This should go away once the stats are in As the method is only there to know what tier the key is going to be fetched from
        Parameters:
        key -
        Returns:
      • getInMemorySizeInBytes

        @Deprecated
        long getInMemorySizeInBytes()
        Deprecated.
        CacheTier could keep hold of the PoolAccessors for each tier... But what about non pooled resources ?
        Returns:
      • getOffHeapSizeInBytes

        @Deprecated
        long getOffHeapSizeInBytes()
        Deprecated.
        CacheTier could keep hold of the PoolAccessors for each tier... But what about non pooled resources ?
        Returns:
      • getOnDiskSizeInBytes

        @Deprecated
        long getOnDiskSizeInBytes()
        Deprecated.
        CacheTier could keep hold of the PoolAccessors for each tier... But what about non pooled resources ?
        Returns:
      • recalculateSize

        @Deprecated
        void recalculateSize​(K key)
        Deprecated.
        This is evil! Don't call this!
        Parameters:
        key - the key to perform the recalculation for
      • getEvictionPolicy

        @Deprecated
        Policy getEvictionPolicy()
        Deprecated.
        queries the potential eviction policy for the heap caching tier
        Returns:
        the policy
      • setEvictionPolicy

        @Deprecated
        void setEvictionPolicy​(Policy policy)
        Deprecated.
        sets the eviction policy on the heap caching tier
        Parameters:
        policy - the policy to use