Interface Cache

All Superinterfaces:
InvalidationTarget
All Known Implementing Classes:
DefaultCache, RegionCacheAdapter

public interface Cache extends InvalidationTarget
  • Field Details

    • CACHEKEY_HJMP

      static final String CACHEKEY_HJMP
    • CACHEKEY_ENTITY

      static final String CACHEKEY_ENTITY
    • CACHEKEY_FIND

      static final String CACHEKEY_FIND
    • CACHEKEY_FLEXSEARCH

      static final String CACHEKEY_FLEXSEARCH
    • CACHEKEY_ENTITYISALIVE

      static final String CACHEKEY_ENTITYISALIVE
    • CACHEKEY_JALOITEMDATA

      static final String CACHEKEY_JALOITEMDATA
    • CACHEKEY_JALOTYPE

      static final String CACHEKEY_JALOTYPE
    • CACHEKEY_JALOITEMCACHE

      static final String CACHEKEY_JALOITEMCACHE
    • CACHEKEY_CUSTOM

      static final String CACHEKEY_CUSTOM
    • CACHEKEY_C2LMANAGER

      static final String CACHEKEY_C2LMANAGER
    • CONFIG_CACHE_MAIN

      static final String CONFIG_CACHE_MAIN
      See Also:
    • CONFIG_CACHE_SHARED

      static final String CONFIG_CACHE_SHARED
      See Also:
    • DEFAULT_CACHE_SHARED

      static final boolean DEFAULT_CACHE_SHARED
      See Also:
    • DEFAULT_CACHE_MAIN

      static final int DEFAULT_CACHE_MAIN
      See Also:
    • LIMIT_CACHE_MAIN

      static final int LIMIT_CACHE_MAIN
      See Also:
    • CONFIG_CONCURRENCY_LEVEL

      static final String CONFIG_CONCURRENCY_LEVEL
      See Also:
    • CONFIG_EVICTION_POLICY

      static final String CONFIG_EVICTION_POLICY
      See Also:
    • CONFIG_FORCE_EXCLUSIVE_CALCULATION

      static final String CONFIG_FORCE_EXCLUSIVE_CALCULATION
      See Also:
  • Method Details

    • setEnabled

      void setEnabled(boolean enabled)
      enables/disables the cache.
      Parameters:
      enabled - true for enabling the cache, false otherwise.
    • getOrAddUnit

      gets value stored in the cache or loads it.
      Throws exception wrapped into RuntimeException
    • getUnit

      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(Object[] key, int invalidationType)
      execute invalidation (not delayed to transaction end)
      Specified by:
      invalidate in interface InvalidationTarget
      Parameters:
      key - may be an incomplete key, for group invalidation
    • getAbstractCacheUnit

      AbstractCacheUnit getAbstractCacheUnit(String firstKeyElement, String secondKeyElement, String thirdKeyElement, PK fourthKeyElement)
      for performance optimizations: get a existing cache unit; the key of the cache unit must consist of exactly three elements
      Throws:
      CacheValueLoadException
      CacheRegionNotSpecifiedException
    • clearStats

      void clearStats()
      Clears the collected cache statistics.
    • statsEnabled

      boolean statsEnabled()
      Returns true if the statistics for the cache are enabled. This can be modified with the method setStatsEnabled(boolean). Collecting the statistics is very memory intensive - use clearStats() 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()
      Returns true if no cache statistics are collected. addToStatistics(Object[], boolean) was not called yet)
      Returns:
      false otherwise
    • getStatistics

      Set<? extends CacheStatisticsEntry> getStatistics(int upperBound, int lowerBound)
      Returns as Set the collected cache statistics. Each set entry is a DefaultCacheStatisticsEntry. With the parameters upperBound and lowerBound a reduced Set will be returned. DefaultCacheStatisticsEntry.getFactor() must be between upperBound and lowerBound.
      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() or clearStats().
    • getRemoveCount

      long getRemoveCount()
      Returns:
      how many entities where removed from the cache since creation of the cache. This is reseted by calling clear() or clearStats().
    • getGetCount

      long getGetCount()
      Returns:
      how many entities where requested from the cache since creation of the cache. This is reseted by calling clear() or clearStats().
    • 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() or clearStats().
    • 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

      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)