Class AbstractCacheUnit

java.lang.Object
de.hybris.platform.cache.AbstractCacheUnit
All Implemented Interfaces:
CacheValueLoader
Direct Known Subclasses:
AbstractRegioncacheRegistrableUnit, AnonymousCacheUnit, CustomCacheUnit, CustomCacheUnit, DefaultSLDDataContainerProvider.SLDItemBulkLoadUnit, DefaultSLDDataContainerProvider.SLDItemLoadUnit, FinderResult, GenericBMPBean.GenericItemEntityStateCacheUnit, IsItemAliveCheckUnit, JaloItemCacheUnit, JaloTypeCacheUnit, RelationCacheUnit, SLDPermissionManagementStrategy.AclCacheUnit

public abstract class AbstractCacheUnit extends Object implements CacheValueLoader
  • Field Details

    • INVALIDATIONTYPE_MODIFIED

      public static final int INVALIDATIONTYPE_MODIFIED
      See Also:
    • INVALIDATIONTYPE_REMOVED

      public static final int INVALIDATIONTYPE_REMOVED
      See Also:
    • INVALIDATIONTYPE_CREATED

      public static final int INVALIDATIONTYPE_CREATED
      See Also:
    • INVALIDATIONTYPE_MODIFIED_STRING

      public static final String INVALIDATIONTYPE_MODIFIED_STRING
    • INVALIDATIONTYPE_REMOVED_STRING

      public static final String INVALIDATIONTYPE_REMOVED_STRING
    • UNKNOWN

      public static Object UNKNOWN
    • cacheKey

      protected volatile CacheKey cacheKey
  • Constructor Details

    • AbstractCacheUnit

      public AbstractCacheUnit(Cache cache, Tenant tenant)
    • AbstractCacheUnit

      public AbstractCacheUnit(Cache cache, String tenantId)
      For testing
    • AbstractCacheUnit

      public AbstractCacheUnit(Cache cache)
  • Method Details

    • createKey

      public abstract Object[] createKey()
    • getKey

      public CacheKey getKey()
    • getLoader

      public CacheValueLoader<? extends AbstractCacheUnit> getLoader()
    • load

      public Object load(CacheKey key) throws CacheValueLoadException
      We do not perform compute not to hit database several times from different threads.
      Another reason is to keep lifecycle of hooks in the same order. addedToCacheBeforeComputation() is called here other callbacks in the RegionCacheAdapter.
      Specified by:
      load in interface CacheValueLoader
      Throws:
      CacheValueLoadException
    • compute

      public abstract Object compute() throws Exception
      Throws:
      Exception
    • getCache

      protected Cache getCache()
    • isValueKnown

      public boolean isValueKnown()
    • isCachingSupported

      public boolean isCachingSupported()
    • getTenantID

      public String getTenantID()
    • getKeyAsArray

      public final Object[] getKeyAsArray()
    • useCache

      protected boolean useCache()
    • get

      public final Object get() throws Exception
      Throws:
      Exception
    • getWithoutCompute

      public Object getWithoutCompute()
    • getWithoutComputeIgnoringTransaction

      public Object getWithoutComputeIgnoringTransaction()
    • getInvalidationTopicDepth

      public int getInvalidationTopicDepth()
      Returns the number of elements of the key that are elements of the invalidation topic key. This method must be implemented for all AbstractCacheUnits that are invalidated externally.
    • hintValue

      protected void hintValue(Object newValue)
      This method allows direct setting of the value (without execution of compute()); it can be used if the value is available as result of some other operation; callers guarantee that the given value is equal to the Object that would be returned by a call to compute The new value will only be set if the object is not already in the cache.
    • invalidate

      public void invalidate(int invalidationType)
      mark the Cache Unit to be invalidated upon commit invalidationType is one of the constants (modified or remove)
    • removedFromCache

      public void removedFromCache()
    • addedToCacheBeforeComputation

      public void addedToCacheBeforeComputation()
    • executeInvalidation

      public void executeInvalidation()
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object