Class MaxCacheSizePolicy<K,​V>

  • All Implemented Interfaces:
    RetentionPolicy

    public class MaxCacheSizePolicy<K,​V>
    extends Object
    implements RetentionPolicy
    The retention policy for

    Created by Jeff Gaynor
    on Nov 12, 2010 at 9:51:36 AM

    • Constructor Detail

      • MaxCacheSizePolicy

        public MaxCacheSizePolicy​(Map<K,​V> cache,
                                  int maxCacheSize)
    • Method Detail

      • setMap

        public void setMap​(Map<K,​V> map)
      • getMaximumSize

        public int getMaximumSize()
      • setMaximumSize

        public void setMaximumSize​(int maximumSize)
      • applies

        public boolean applies()
        Description copied from interface: RetentionPolicy
        If this applies to the current cache. While this is true, the RetentionPolicy.retain(Object, Object) method will be applied to each element of the cache. When false, this policy will be skipped.
        E.g. for a cache that limits the number of cached items, there is no reason to check every item in the cache directly if the cache size is below a certain threshold.
        Specified by:
        applies in interface RetentionPolicy<K,​V>
        Returns:
      • sizeOk

        protected boolean sizeOk()
        Returns true if the size of the cache is ok.
        Returns: