com.fasterxml.jackson.databind.util

Class LRUMap<K,V>

  • All Implemented Interfaces:
    Serializable


    public class LRUMap<K,V>
    extends Object
    implements Serializable
    Helper for simple bounded maps used for reusing lookup values.

    Note that serialization behavior is such that contents are NOT serialized, on assumption that all use cases are for caching where persistence does not make sense. The only thing serialized is the cache size of Map.

    NOTE: since version 2.4.2, this is NOT an LRU-based at all; reason being that it is not possible to use JDK components that do LRU _AND_ perform well wrt synchronization on multi-core systems. So we choose efficient synchronization over potentially more effecient handling of entries.

    See Also:
    Serialized Form
    • Field Detail

      • _maxEntries

        protected final transient int _maxEntries
      • _jdkSerializeMaxEntries

        protected transient int _jdkSerializeMaxEntries
        Ugly hack, to work through the requirement that _value is indeed final, and that JDK serialization won't call ctor(s) if Serializable is implemented.
        Since:
        2.1
    • Constructor Detail

      • LRUMap

        public LRUMap(int initialEntries,
              int maxEntries)
    • Method Detail

      • put

        public V put(K key,
            V value)
      • clear

        public void clear()
      • size

        public int size()
      • readResolve

        protected Object readResolve()

Copyright © 2014-2015 FasterXML. All Rights Reserved.