Class SoftHashMap<K,​V>

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

    public class SoftHashMap<K,​V>
    extends AbstractMap<K,​V>
    A in memory cache using soft references. (can be garbage collected) This code is based on: http://java-interview-faqs.blogspot.com/2008/09/building-faster-and-efficient-cache.html

    Note that entrySet() is not implemented and therefore many methods such as keySet(), containsKey(), values() etc do not work.

    This class is therefore best used as a cache simply to put and get items by a known key

    • Constructor Detail

      • SoftHashMap

        public SoftHashMap()
      • SoftHashMap

        public SoftHashMap​(int hardSize)
        Parameters:
        hardSize - A maximum number of items to maintain hard references to that will not be eligible for garbage collection