Package de.hybris.platform.cache
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,SLDPermissionManagementStrategy.AclCacheUnit
public abstract class AbstractCacheUnit extends java.lang.Object implements CacheValueLoader
-
-
Field Summary
Fields Modifier and Type Field Description protected CacheKeycacheKeystatic intINVALIDATIONTYPE_CREATEDstatic intINVALIDATIONTYPE_MODIFIEDstatic java.lang.StringINVALIDATIONTYPE_MODIFIED_STRINGstatic intINVALIDATIONTYPE_REMOVEDstatic java.lang.StringINVALIDATIONTYPE_REMOVED_STRINGstatic java.lang.ObjectUNKNOWN
-
Constructor Summary
Constructors Constructor Description AbstractCacheUnit(Cache cache)AbstractCacheUnit(Cache cache, Tenant tenant)AbstractCacheUnit(Cache cache, java.lang.String tenantId)For testing
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddedToCacheBeforeComputation()abstract java.lang.Objectcompute()abstract java.lang.Object[]createKey()booleanequals(java.lang.Object object)voidexecuteInvalidation()java.lang.Objectget()protected CachegetCache()intgetInvalidationTopicDepth()Returns the number of elements of the key that are elements of the invalidation topic key.CacheKeygetKey()java.lang.Object[]getKeyAsArray()CacheValueLoader<? extends AbstractCacheUnit>getLoader()java.lang.StringgetTenantID()java.lang.ObjectgetWithoutCompute()java.lang.ObjectgetWithoutComputeIgnoringTransaction()inthashCode()protected voidhintValue(java.lang.Object newValue)This method allows direct setting of the value (without execution ofcompute()); 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.voidinvalidate(int invalidationType)mark the Cache Unit to be invalidated upon commit invalidationType is one of the constants (modified or remove)booleanisCachingSupported()booleanisValueKnown()java.lang.Objectload(CacheKey key)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.voidremovedFromCache()java.lang.StringtoString()protected booleanuseCache()
-
-
-
Field Detail
-
INVALIDATIONTYPE_MODIFIED
public static final int INVALIDATIONTYPE_MODIFIED
- See Also:
- Constant Field Values
-
INVALIDATIONTYPE_REMOVED
public static final int INVALIDATIONTYPE_REMOVED
- See Also:
- Constant Field Values
-
INVALIDATIONTYPE_CREATED
public static final int INVALIDATIONTYPE_CREATED
- See Also:
- Constant Field Values
-
INVALIDATIONTYPE_MODIFIED_STRING
public static final java.lang.String INVALIDATIONTYPE_MODIFIED_STRING
-
INVALIDATIONTYPE_REMOVED_STRING
public static final java.lang.String INVALIDATIONTYPE_REMOVED_STRING
-
UNKNOWN
public static java.lang.Object UNKNOWN
-
cacheKey
protected volatile CacheKey cacheKey
-
-
Method Detail
-
createKey
public abstract java.lang.Object[] createKey()
-
getKey
public CacheKey getKey()
-
getLoader
public CacheValueLoader<? extends AbstractCacheUnit> getLoader()
-
load
public java.lang.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:
loadin interfaceCacheValueLoader- Throws:
CacheValueLoadException
-
compute
public abstract java.lang.Object compute() throws java.lang.Exception- Throws:
java.lang.Exception
-
getCache
protected Cache getCache()
-
isValueKnown
public boolean isValueKnown()
-
isCachingSupported
public boolean isCachingSupported()
-
getTenantID
public java.lang.String getTenantID()
-
getKeyAsArray
public final java.lang.Object[] getKeyAsArray()
-
useCache
protected boolean useCache()
-
get
public final java.lang.Object get() throws java.lang.Exception- Throws:
java.lang.Exception
-
getWithoutCompute
public java.lang.Object getWithoutCompute()
-
getWithoutComputeIgnoringTransaction
public java.lang.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(java.lang.Object newValue)
This method allows direct setting of the value (without execution ofcompute()); 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:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-