Class IMapRegionCache

java.lang.Object
com.hazelcast.hibernate.distributed.IMapRegionCache
All Implemented Interfaces:
RegionCache, org.hibernate.cache.spi.ExtendedStatisticsSupport, org.hibernate.cache.spi.Region

public class IMapRegionCache extends Object implements RegionCache
A RegionCache implementation based on the underlying IMap

Note, IMap locks are intentionally not used in this class. Hibernate region caches make use of a concept called soft-locking which has the following properties:

  • Multiple transactions can soft-lock an entry concurrently
  • While an entry is soft-locked, the value of the cache entry is always null
  • An entry is unlocked from a soft-lock when all transactions complete
  • An entry is unlocked if it reaches the configured lock timeout
These requirements are incompatible with IMap locks
  • Constructor Details

    • IMapRegionCache

      public IMapRegionCache(org.hibernate.cache.spi.RegionFactory regionFactory, String name, com.hazelcast.core.HazelcastInstance hazelcastInstance)
  • Method Details

    • afterUpdate

      public void afterUpdate(Object key, Object newValue, Object newVersion)
      Specified by:
      afterUpdate in interface RegionCache
    • contains

      public boolean contains(Object key)
      Specified by:
      contains in interface RegionCache
    • evictData

      public void evictData()
      Specified by:
      evictData in interface RegionCache
    • evictData

      public void evictData(Object key)
      Specified by:
      evictData in interface RegionCache
    • get

      public Object get(Object key, long txTimestamp)
      Specified by:
      get in interface RegionCache
    • getElementCountInMemory

      public long getElementCountInMemory()
      Returns the number of in-memory entries (without backups) for a particular application instance or -1 if using Hazelcast Client
      Specified by:
      getElementCountInMemory in interface org.hibernate.cache.spi.ExtendedStatisticsSupport
    • getName

      public String getName()
      Specified by:
      getName in interface org.hibernate.cache.spi.Region
    • getRegionFactory

      public org.hibernate.cache.spi.RegionFactory getRegionFactory()
      Specified by:
      getRegionFactory in interface org.hibernate.cache.spi.Region
    • getSizeInMemory

      public long getSizeInMemory()
      Returns the total in-memory cost in bytes (including IMap, Near Cache, backup, Merkle trees) for a particular application instance or -1 if using Hazelcast Client
      Specified by:
      getSizeInMemory in interface org.hibernate.cache.spi.ExtendedStatisticsSupport
    • put

      public boolean put(Object key, Object value, long txTimestamp, Object version)
      Specified by:
      put in interface RegionCache
    • unlockItem

      public void unlockItem(Object key, org.hibernate.cache.spi.access.SoftLock lock)
      Specified by:
      unlockItem in interface RegionCache