Class CHMCache

java.lang.Object
com.maxmind.db.CHMCache
All Implemented Interfaces:
NodeCache

public class CHMCache extends Object implements NodeCache
A simplistic cache using a ConcurrentHashMap. There's no eviction policy, it just fills up until reaching the specified capacity (or close enough at least, bounds check is not atomic :)
  • Constructor Details

    • CHMCache

      public CHMCache()
      Creates a new cache with the default capacity.
    • CHMCache

      public CHMCache(int capacity)
      Creates a new cache with the specified capacity.
      Parameters:
      capacity - the maximum number of elements the cache can hold before starting to evict them
  • Method Details

    • get

      public DecodedValue get(CacheKey key, NodeCache.Loader loader) throws IOException
      Description copied from interface: NodeCache
      This method returns the value for the key. If the key is not in the cache then the loader is called to load the value.
      Specified by:
      get in interface NodeCache
      Parameters:
      key - the key to look up
      loader - the loader to use if the key is not in the cache
      Returns:
      the value for the key
      Throws:
      IOException - if there is an error loading the value