Class DefaultCacheRegion

  • All Implemented Interfaces:
    CacheRegion

    public class DefaultCacheRegion
    extends java.lang.Object
    implements CacheRegion
    Default cache region implementation.
    For the synchronization it uses ReentrantReadWriteLock one for whole cache map. It is really inefficient then.
    • Field Detail

      • handledTypes

        protected java.lang.String[] handledTypes
      • name

        protected final java.lang.String name
      • sharedLock

        protected final java.util.concurrent.locks.ReentrantReadWriteLock sharedLock
      • statsEnabled

        protected volatile boolean statsEnabled
      • exclusiveComputation

        protected final boolean exclusiveComputation
    • Constructor Detail

      • DefaultCacheRegion

        public DefaultCacheRegion​(java.lang.String name)
      • DefaultCacheRegion

        public DefaultCacheRegion​(java.lang.String name,
                                  CacheMap cacheMap,
                                  java.lang.String[] handledTypes)
      • DefaultCacheRegion

        public DefaultCacheRegion​(java.lang.String name,
                                  boolean exclusiveComputation,
                                  boolean statsEnabled)
      • DefaultCacheRegion

        public DefaultCacheRegion​(java.lang.String name,
                                  CacheMap cacheMap,
                                  CacheStatistics stats,
                                  java.lang.String[] handledTypes)
      • DefaultCacheRegion

        public DefaultCacheRegion​(java.lang.String name,
                                  CacheMap cacheMap,
                                  CacheStatistics stats,
                                  java.lang.String[] handledTypes,
                                  boolean exclusiveComputation,
                                  boolean statsEnabled)
      • DefaultCacheRegion

        public DefaultCacheRegion​(java.lang.String name,
                                  int maxEntries,
                                  boolean exclusiveComputation,
                                  boolean statsEnabled)
      • DefaultCacheRegion

        @Deprecated
        public DefaultCacheRegion​(java.lang.String name,
                                  int maxEntries,
                                  boolean exclusiveComputation,
                                  java.lang.String evictionPolicy,
                                  boolean statsEnabled)
        Deprecated.
        since 1811
        Parameters:
        evictionPolicy -
      • DefaultCacheRegion

        public DefaultCacheRegion​(java.lang.String name,
                                  int maxEntries)
    • Method Detail

      • init

        @PostConstruct
        public void init()
      • get

        public java.lang.Object get​(CacheKey key)
        Description copied from interface: CacheRegion
        Gets value from the cache. If value is absent returns null. Must be thread safe.
        Specified by:
        get in interface CacheRegion
      • getMaxReachedSize

        public long getMaxReachedSize()
        Description copied from interface: CacheRegion
        Returns number of elements currently in the cache
        Specified by:
        getMaxReachedSize in interface CacheRegion
      • invalidate

        public java.lang.Object invalidate​(CacheKey key,
                                           boolean fireEventsEvenIfNotRemoved)
        Description copied from interface: CacheRegion
        Invalidates (removes) value from cache map. Must be thread safe.
        Specified by:
        invalidate in interface CacheRegion
        Returns:
        an object invalidated from cache.
      • getName

        public java.lang.String getName()
        Description copied from interface: CacheRegion
        Gets region name. Needed to resolve proper cache region.
        Specified by:
        getName in interface CacheRegion
      • getHandledTypes

        public java.lang.String[] getHandledTypes()
        Description copied from interface: CacheRegion
        Gets types which can be stored in the region. Needed to resolve proper cache region.
        Special type names are defined in RegionType.
        Specified by:
        getHandledTypes in interface CacheRegion
      • setHandledTypes

        public void setHandledTypes​(java.lang.String[] handledTypes)
      • getCacheMap

        public CacheMap getCacheMap()
        Returns:
        the cacheMap
      • setCacheMap

        public void setCacheMap​(CacheMap cacheMap)
        Parameters:
        cacheMap - the cacheMap to set
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getCacheMaxEntries

        public long getCacheMaxEntries()
        Description copied from interface: CacheRegion
        Gets number of cache entries above which invalidation occurs.
        Specified by:
        getCacheMaxEntries in interface CacheRegion
      • clearCache

        public void clearCache()
        Description copied from interface: CacheRegion
        Removes all elements from cache.
        Specified by:
        clearCache in interface CacheRegion
      • toString

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

        public java.util.Collection<CacheKey> getAllKeys()
        Description copied from interface: CacheRegion
        Returns all keys currently stored in this region.
        Specified by:
        getAllKeys in interface CacheRegion
      • remove

        public java.lang.Object remove​(CacheKey key,
                                       boolean fireEvents)
        Description copied from interface: CacheRegion
        Removes value stored on the key specified. This method does not update statistics. Returns value removed or null.
        Specified by:
        remove in interface CacheRegion