Class AbstractCacheUnit

    • 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
    • Constructor Detail

      • AbstractCacheUnit

        public AbstractCacheUnit​(Cache cache,
                                 Tenant tenant)
      • AbstractCacheUnit

        public AbstractCacheUnit​(Cache cache,
                                 java.lang.String tenantId)
        For testing
      • AbstractCacheUnit

        public AbstractCacheUnit​(Cache cache)
    • Method Detail

      • createKey

        public abstract java.lang.Object[] createKey()
      • 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 interface CacheValueLoader
        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 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.
      • 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 class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object