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 CacheKey
cacheKey
static int
INVALIDATIONTYPE_CREATED
static int
INVALIDATIONTYPE_MODIFIED
static java.lang.String
INVALIDATIONTYPE_MODIFIED_STRING
static int
INVALIDATIONTYPE_REMOVED
static java.lang.String
INVALIDATIONTYPE_REMOVED_STRING
static java.lang.Object
UNKNOWN
-
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 void
addedToCacheBeforeComputation()
abstract java.lang.Object
compute()
abstract java.lang.Object[]
createKey()
boolean
equals(java.lang.Object object)
void
executeInvalidation()
java.lang.Object
get()
protected Cache
getCache()
int
getInvalidationTopicDepth()
Returns the number of elements of the key that are elements of the invalidation topic key.CacheKey
getKey()
java.lang.Object[]
getKeyAsArray()
CacheValueLoader<? extends AbstractCacheUnit>
getLoader()
java.lang.String
getTenantID()
java.lang.Object
getWithoutCompute()
java.lang.Object
getWithoutComputeIgnoringTransaction()
int
hashCode()
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.void
invalidate(int invalidationType)
mark the Cache Unit to be invalidated upon commit invalidationType is one of the constants (modified or remove)boolean
isCachingSupported()
boolean
isValueKnown()
java.lang.Object
load(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.void
removedFromCache()
java.lang.String
toString()
protected boolean
useCache()
-
-
-
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:
load
in 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:
hashCode
in classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-