Class HibernateClusterAwareCacheManager

  • All Implemented Interfaces:
    com.atlassian.cache.CacheFactory, com.atlassian.cache.CacheManager, org.springframework.beans.factory.InitializingBean

    @Internal
    public class HibernateClusterAwareCacheManager
    extends Object
    implements com.atlassian.cache.CacheManager, org.springframework.beans.factory.InitializingBean
    Make sure Hibernate L2 caches are flushed correctly in Data Center. In Data Center, Hibernate L2 caches are backed by Hazelcast and are divided into multiple regions. By default, all these regions are stored as distributed IMaps except for query cache region which is stored locally on each node thus not managed by CacheManager. Due to how query caching works in Hibernate, query caches *must* always be flushed whenever timestamp caches are flushed. This class publishes a cluster event to flush query caches on *each* node when timestamp caches are flushed via CacheManager
    Since:
    6.14
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • onClusterCacheFlush

        @EventListener
        public void onClusterCacheFlush​(ClusterEventWrapper wrapper)
        Timestamp cache region has been flushed, time to flush all local query caches. Due to nature of cluster events, nodes other than the flush triggering node may have staled data until this event is propagated to them. In rare circumstances, this event may even not be delivered altogether. In that case, Hibernate optimistic locking is our last defence.
      • getCaches

        public @NonNull Collection<com.atlassian.cache.Cache<?,​?>> getCaches()
        Specified by:
        getCaches in interface com.atlassian.cache.CacheManager
      • getManagedCaches

        public @NonNull Collection<com.atlassian.cache.ManagedCache> getManagedCaches()
        Specified by:
        getManagedCaches in interface com.atlassian.cache.CacheManager
      • flushCaches

        public void flushCaches()
        Specified by:
        flushCaches in interface com.atlassian.cache.CacheManager
      • getManagedCache

        public @Nullable com.atlassian.cache.ManagedCache getManagedCache​(@NonNull String name)
        Specified by:
        getManagedCache in interface com.atlassian.cache.CacheManager
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface com.atlassian.cache.CacheManager
      • getCachedReference

        public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference​(@NonNull String name,
                                                                                      @NonNull com.atlassian.cache.Supplier<V> supplier)
        Specified by:
        getCachedReference in interface com.atlassian.cache.CacheFactory
      • getCachedReference

        public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference​(@NonNull String name,
                                                                                      @NonNull com.atlassian.cache.Supplier<V> supplier,
                                                                                      @NonNull com.atlassian.cache.CacheSettings required)
        Specified by:
        getCachedReference in interface com.atlassian.cache.CacheFactory
      • getCachedReference

        public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference​(@NonNull Class<?> owningClass,
                                                                                      @NonNull String name,
                                                                                      @NonNull com.atlassian.cache.Supplier<V> supplier)
        Specified by:
        getCachedReference in interface com.atlassian.cache.CacheFactory
      • getCachedReference

        public <V> @NonNull com.atlassian.cache.CachedReference<V> getCachedReference​(@NonNull Class<?> owningClass,
                                                                                      @NonNull String name,
                                                                                      @NonNull com.atlassian.cache.Supplier<V> supplier,
                                                                                      @NonNull com.atlassian.cache.CacheSettings required)
        Specified by:
        getCachedReference in interface com.atlassian.cache.CacheFactory
      • getCache

        public <K,​V> @NonNull com.atlassian.cache.Cache<K,​V> getCache​(@NonNull String name)
        Specified by:
        getCache in interface com.atlassian.cache.CacheFactory
      • getCache

        public <K,​V> @NonNull com.atlassian.cache.Cache<K,​V> getCache​(@NonNull Class<?> owningClass,
                                                                                  @NonNull String name)
        Specified by:
        getCache in interface com.atlassian.cache.CacheFactory
      • getCache

        public <K,​V> @NonNull com.atlassian.cache.Cache<K,​V> getCache​(@NonNull String name,
                                                                                  @Nullable com.atlassian.cache.CacheLoader<K,​V> loader)
        Specified by:
        getCache in interface com.atlassian.cache.CacheFactory
      • getCache

        public <K,​V> @NonNull com.atlassian.cache.Cache<K,​V> getCache​(@NonNull String name,
                                                                                  @Nullable com.atlassian.cache.CacheLoader<K,​V> loader,
                                                                                  @NonNull com.atlassian.cache.CacheSettings required)
        Specified by:
        getCache in interface com.atlassian.cache.CacheFactory
      • getCache

        public <K,​V> @NonNull com.atlassian.cache.Cache<K,​V> getCache​(@NonNull String name,
                                                                                  @NonNull Class<K> keyType,
                                                                                  @NonNull Class<V> valueType)
        Specified by:
        getCache in interface com.atlassian.cache.CacheFactory