public abstract class AbstractCacheUnit extends java.lang.Object implements CacheValueLoader
| Modifier and Type | Field and 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 and Description |
|---|
AbstractCacheUnit(Cache cache) |
AbstractCacheUnit(Cache cache,
java.lang.String tenantId)
For testing
|
AbstractCacheUnit(Cache cache,
Tenant tenant) |
| Modifier and Type | Method and 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 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. |
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() |
public static final int INVALIDATIONTYPE_MODIFIED
public static final int INVALIDATIONTYPE_REMOVED
public static final int INVALIDATIONTYPE_CREATED
public static final java.lang.String INVALIDATIONTYPE_MODIFIED_STRING
public static final java.lang.String INVALIDATIONTYPE_REMOVED_STRING
public static java.lang.Object UNKNOWN
protected volatile CacheKey cacheKey
public AbstractCacheUnit(Cache cache, java.lang.String tenantId)
public AbstractCacheUnit(Cache cache)
public abstract java.lang.Object[] createKey()
public CacheKey getKey()
public CacheValueLoader<? extends AbstractCacheUnit> getLoader()
public java.lang.Object load(CacheKey key) throws CacheValueLoadException
load in interface CacheValueLoaderCacheValueLoadExceptionpublic abstract java.lang.Object compute()
throws java.lang.Exception
java.lang.Exceptionprotected Cache getCache()
public boolean isValueKnown()
public boolean isCachingSupported()
public java.lang.String getTenantID()
public final java.lang.Object[] getKeyAsArray()
protected boolean useCache()
public final java.lang.Object get()
throws java.lang.Exception
java.lang.Exceptionpublic java.lang.Object getWithoutCompute()
public java.lang.Object getWithoutComputeIgnoringTransaction()
public int getInvalidationTopicDepth()
protected void hintValue(java.lang.Object newValue)
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.public void invalidate(int invalidationType)
public void removedFromCache()
public void addedToCacheBeforeComputation()
public void executeInvalidation()
public final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2018 SAP SE. All Rights Reserved.