Class MappedCache<KEYTYPE,KEYSTORETYPE,VALUETYPE>

java.lang.Object
com.helger.commons.cache.MappedCache<KEYTYPE,KEYSTORETYPE,VALUETYPE>
Type Parameters:
KEYTYPE - The cache source type
KEYSTORETYPE - The internal storage key type
VALUETYPE - The cache value type
All Implemented Interfaces:
ICache<KEYTYPE,VALUETYPE>, IMutableCache<KEYTYPE,VALUETYPE>, IHasSize, IHasName
Direct Known Subclasses:
Cache

@ThreadSafe public class MappedCache<KEYTYPE,KEYSTORETYPE,VALUETYPE> extends Object implements IMutableCache<KEYTYPE,VALUETYPE>
Base implementation of ICache and IMutableCache.
Since:
9.3.8 generalized from the existing Cache class.
Author:
Philip Helger
  • Field Details

    • STATISTICS_PREFIX

      public static final String STATISTICS_PREFIX
      The prefix to be used for statistics elements
      See Also:
    • NO_MAX_SIZE

      public static final int NO_MAX_SIZE
      A constant indicating, that a cache has no max size
      See Also:
    • m_aRWLock

      protected final SimpleReadWriteLock m_aRWLock
  • Constructor Details

    • MappedCache

      public MappedCache(@Nonnull Function<KEYTYPE,KEYSTORETYPE> aCacheKeyProvider, @Nonnull Function<KEYTYPE,VALUETYPE> aValueProvider, int nMaxSize, @Nonnull @Nonempty String sCacheName, boolean bAllowNullValues)
      Constructor
      Parameters:
      aCacheKeyProvider - The cache key provider, that takes any KEYTYPE and creates a non-null KEYSTORETYPE instance. May not be null.
      aValueProvider - The cache value provider. The value to be cached may be null depending on the parameter bAllowNullValues. May not be null.
      nMaxSize - The maximum size of the cache. All values ≤ 0 indicate an unlimited size.
      sCacheName - The internal name of the cache. May neither be null nor empty. This name is NOT checked for uniqueness.
      bAllowNullValues - true if null values are allowed to be in the cache, false if not.
  • Method Details