Package de.hybris.platform.cache
Interface Cache
-
- All Superinterfaces:
InvalidationTarget
- All Known Implementing Classes:
DefaultCache
,RegionCacheAdapter
public interface Cache extends InvalidationTarget
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CACHEKEY_C2LMANAGER
static java.lang.String
CACHEKEY_CUSTOM
static java.lang.String
CACHEKEY_ENTITY
static java.lang.String
CACHEKEY_ENTITYISALIVE
static java.lang.String
CACHEKEY_FIND
static java.lang.String
CACHEKEY_FLEXSEARCH
static java.lang.String
CACHEKEY_HJMP
static java.lang.String
CACHEKEY_JALOITEMCACHE
static java.lang.String
CACHEKEY_JALOITEMDATA
static java.lang.String
CACHEKEY_JALOTYPE
static java.lang.String
CONFIG_CACHE_MAIN
static java.lang.String
CONFIG_CACHE_SHARED
static java.lang.String
CONFIG_CONCURRENCY_LEVEL
static java.lang.String
CONFIG_EVICTION_POLICY
static java.lang.String
CONFIG_FORCE_EXCLUSIVE_CALCULATION
static int
DEFAULT_CACHE_MAIN
static boolean
DEFAULT_CACHE_SHARED
static int
LIMIT_CACHE_MAIN
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
void
clearStats()
Clears the collected cache statistics.void
destroy()
Method called by tennant to free resources before object is finalizedvoid
enableStats(boolean enabled)
AbstractCacheUnit
getAbstractCacheUnit(java.lang.String firstKeyElement, java.lang.String secondKeyElement, java.lang.String thirdKeyElement, PK fourthKeyElement)
for performance optimizations: get a existing cache unit; the key of the cache unit must consist of exactly three elementslong
getAddCount()
long
getGetCount()
int
getMaxAllowedSize()
The upper limit for the cache.int
getMaxReachedSize()
the maximum reached number of entries since creation of the cache.long
getMissCount()
AbstractCacheUnit
getOrAddUnit(AbstractCacheUnit unit)
gets value stored in the cache or loads it.
Throws exception wrapped into RuntimeExceptionlong
getRemoveCount()
<T> T
getRequestCacheContent(SingletonCreator.Creator<T> creator)
<T> T
getRequestCacheContentIfExists(SingletonCreator.Creator<T> creator)
int
getSize()
<T> T
getStaticCacheContent(SingletonCreator.Creator<T> creator)
java.util.Set<? extends CacheStatisticsEntry>
getStatistics(int upperBound, int lowerBound)
Returns asSet
the collected cache statistics.Tenant
getTenant()
get the tenant this cache is created for.java.lang.String
getTenantId()
AbstractCacheUnit
getUnit(AbstractCacheUnit unit)
void
invalidate(java.lang.Object[] key, int invalidationType)
execute invalidation (not delayed to transaction end)boolean
isForceExclusiveComputation()
checks if AbstractCacheUnit should synchronize load function.boolean
isStatsEmpty()
Returnstrue
if no cache statistics are collected.void
removeUnit(AbstractCacheUnit unit)
Removes a cache unit from this cache.void
setEnabled(boolean enabled)
enables/disables the cache.void
setStatsEnabled(boolean enabled)
Enables or disables the cache statistics.boolean
statsEnabled()
Returnstrue
if the statistics for the cache are enabled.
-
-
-
Field Detail
-
CACHEKEY_HJMP
static final java.lang.String CACHEKEY_HJMP
-
CACHEKEY_ENTITY
static final java.lang.String CACHEKEY_ENTITY
-
CACHEKEY_FIND
static final java.lang.String CACHEKEY_FIND
-
CACHEKEY_FLEXSEARCH
static final java.lang.String CACHEKEY_FLEXSEARCH
-
CACHEKEY_ENTITYISALIVE
static final java.lang.String CACHEKEY_ENTITYISALIVE
-
CACHEKEY_JALOITEMDATA
static final java.lang.String CACHEKEY_JALOITEMDATA
-
CACHEKEY_JALOTYPE
static final java.lang.String CACHEKEY_JALOTYPE
-
CACHEKEY_JALOITEMCACHE
static final java.lang.String CACHEKEY_JALOITEMCACHE
-
CACHEKEY_CUSTOM
static final java.lang.String CACHEKEY_CUSTOM
-
CACHEKEY_C2LMANAGER
static final java.lang.String CACHEKEY_C2LMANAGER
-
CONFIG_CACHE_MAIN
static final java.lang.String CONFIG_CACHE_MAIN
- See Also:
- Constant Field Values
-
CONFIG_CACHE_SHARED
static final java.lang.String CONFIG_CACHE_SHARED
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_SHARED
static final boolean DEFAULT_CACHE_SHARED
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_MAIN
static final int DEFAULT_CACHE_MAIN
- See Also:
- Constant Field Values
-
LIMIT_CACHE_MAIN
static final int LIMIT_CACHE_MAIN
- See Also:
- Constant Field Values
-
CONFIG_CONCURRENCY_LEVEL
static final java.lang.String CONFIG_CONCURRENCY_LEVEL
- See Also:
- Constant Field Values
-
CONFIG_EVICTION_POLICY
static final java.lang.String CONFIG_EVICTION_POLICY
- See Also:
- Constant Field Values
-
CONFIG_FORCE_EXCLUSIVE_CALCULATION
static final java.lang.String CONFIG_FORCE_EXCLUSIVE_CALCULATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
setEnabled
void setEnabled(boolean enabled)
enables/disables the cache.- Parameters:
enabled
-true
for enabling the cache,false
otherwise.
-
getOrAddUnit
AbstractCacheUnit getOrAddUnit(AbstractCacheUnit unit)
gets value stored in the cache or loads it.
Throws exception wrapped into RuntimeException
-
getUnit
AbstractCacheUnit getUnit(AbstractCacheUnit unit)
- Returns:
- null if no unit with the given key is in the cache
- Throws:
CacheRegionNotSpecifiedException
-
isForceExclusiveComputation
boolean isForceExclusiveComputation()
checks if AbstractCacheUnit should synchronize load function.
-
clear
void clear()
-
removeUnit
void removeUnit(AbstractCacheUnit unit)
Removes a cache unit from this cache.- Parameters:
unit
- the unit to be removed. note that the same of any unit with the same key is removed.
-
invalidate
void invalidate(java.lang.Object[] key, int invalidationType)
execute invalidation (not delayed to transaction end)- Specified by:
invalidate
in interfaceInvalidationTarget
- Parameters:
key
- may be an incomplete key, for group invalidation
-
getAbstractCacheUnit
AbstractCacheUnit getAbstractCacheUnit(java.lang.String firstKeyElement, java.lang.String secondKeyElement, java.lang.String thirdKeyElement, PK fourthKeyElement)
for performance optimizations: get a existing cache unit; the key of the cache unit must consist of exactly three elements
-
clearStats
void clearStats()
Clears the collected cache statistics.
-
statsEnabled
boolean statsEnabled()
Returnstrue
if the statistics for the cache are enabled. This can be modified with the methodsetStatsEnabled(boolean)
. Collecting the statistics is very memory intensive - useclearStats()
frequently.- Returns:
false
otherwise.
-
setStatsEnabled
void setStatsEnabled(boolean enabled)
Enables or disables the cache statistics.- Parameters:
enabled
-true
for enabling the statistics
-
enableStats
void enableStats(boolean enabled)
-
isStatsEmpty
boolean isStatsEmpty()
Returnstrue
if no cache statistics are collected. addToStatistics(Object[], boolean) was not called yet)- Returns:
false
otherwise
-
getStatistics
java.util.Set<? extends CacheStatisticsEntry> getStatistics(int upperBound, int lowerBound)
Returns asSet
the collected cache statistics. Each set entry is aDefaultCacheStatisticsEntry
. With the parametersupperBound
andlowerBound
a reduced Set will be returned.DefaultCacheStatisticsEntry.getFactor()
must be betweenupperBound
andlowerBound
.- Parameters:
upperBound
- the upper bound for the returned set. Each entry factor is equal or less.lowerBound
- the lower bound the the returned set. Each entry factor is greater or equal.- Returns:
- a Set with
DefaultCacheStatisticsEntry
.
-
getMaxAllowedSize
int getMaxAllowedSize()
The upper limit for the cache. this normally equals the setting 'cache.main' and is the number of cache entries that are allowed until the cache mechanism will remove the least recently used entries before adding new ones.- Returns:
- the max allowed size
-
getMaxReachedSize
int getMaxReachedSize()
the maximum reached number of entries since creation of the cache. this is only reseted if Cache#clearCache() is called.
-
getSize
int getSize()
-
getAddCount
long getAddCount()
- Returns:
- how many entities where added to the cache since creation of the cache. This is reseted by calling
clear()
orclearStats()
.
-
getRemoveCount
long getRemoveCount()
- Returns:
- how many entities where removed from the cache since creation of the cache. This is reseted by calling
clear()
orclearStats()
.
-
getGetCount
long getGetCount()
- Returns:
- how many entities where requested from the cache since creation of the cache. This is reseted by calling
clear()
orclearStats()
.
-
getMissCount
long getMissCount()
- Returns:
- how many entities where requested from the cache but wasn't in the cache (yet) since creation of the
cache. This is reseted by calling
clear()
orclearStats()
.
-
destroy
void destroy()
Method called by tennant to free resources before object is finalized
-
getTenant
Tenant getTenant()
get the tenant this cache is created for. The hybris 'internal' cache (Tenant.getCache()
always has a tenant, but it is possible to create your own Cache without assigning to a tenant.- Returns:
- the tenant or null if no tenant set
-
getTenantId
java.lang.String getTenantId()
-
getStaticCacheContent
<T> T getStaticCacheContent(SingletonCreator.Creator<T> creator)
-
getRequestCacheContent
<T> T getRequestCacheContent(SingletonCreator.Creator<T> creator)
-
getRequestCacheContentIfExists
<T> T getRequestCacheContentIfExists(SingletonCreator.Creator<T> creator)
-
-